Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ArbInst.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef ARBINST_HPP 00028 #define ARBINST_HPP 00029 00030 #include "ShVariable.hpp" 00031 00032 namespace shgl { 00033 00036 enum ArbOp { 00037 // VERTEX AND FRAGMENT 00038 00039 // Vector 00040 SH_ARB_ABS, 00041 SH_ARB_FLR, 00042 SH_ARB_FRC, 00043 SH_ARB_LIT, 00044 SH_ARB_MOV, 00045 00046 // Scalar 00047 SH_ARB_EX2, 00048 SH_ARB_LG2, 00049 SH_ARB_RCP, 00050 SH_ARB_RSQ, 00051 00052 // Binary scalar 00053 SH_ARB_POW, 00054 00055 // Binary vector 00056 SH_ARB_ADD, 00057 SH_ARB_DP3, 00058 SH_ARB_DP4, 00059 SH_ARB_DPH, 00060 SH_ARB_DST, 00061 SH_ARB_MAX, 00062 SH_ARB_MIN, 00063 SH_ARB_MUL, 00064 SH_ARB_SGE, 00065 SH_ARB_SLT, 00066 SH_ARB_SUB, 00067 SH_ARB_XPD, 00068 00069 // Trinary 00070 SH_ARB_MAD, 00071 00072 // Swizzling 00073 SH_ARB_SWZ, 00074 00075 // VERTEX ONLY 00076 // Scalar 00077 SH_ARB_EXP, 00078 SH_ARB_LOG, 00079 00080 // FRAGMENT ONLY 00081 // Scalar 00082 SH_ARB_COS, 00083 SH_ARB_SIN, 00084 SH_ARB_SCS, 00085 00086 // Trinary 00087 SH_ARB_CMP, 00088 SH_ARB_LRP, 00089 00090 // Sampling 00091 SH_ARB_TEX, 00092 SH_ARB_TXP, 00093 SH_ARB_TXB, 00094 00095 // KIL 00096 SH_ARB_KIL, 00097 00098 // NV_vertex_program2/NV_fragment_program 00099 SH_ARB_SEQ, 00100 SH_ARB_SGT, 00101 SH_ARB_SLE, 00102 SH_ARB_SNE, 00103 SH_ARB_SFL, 00104 SH_ARB_STR, 00105 00106 // NV_fragment_program 00107 SH_ARB_DDX, 00108 SH_ARB_DDY, 00109 SH_ARB_RFL, 00110 SH_ARB_TXD, 00111 00112 // NV_vertex_program2 00113 SH_ARB_SSG, 00114 SH_ARB_BRA, 00115 SH_ARB_LABEL, // Special label "instruction" 00116 00117 // NV_fragment_program2 00118 SH_ARB_DIV, 00119 SH_ARB_DP2, 00120 SH_ARB_NRM, 00121 SH_ARB_IF, 00122 SH_ARB_ELSE, 00123 SH_ARB_ENDIF, 00124 SH_ARB_REP, 00125 SH_ARB_ENDREP, 00126 SH_ARB_BRK, 00127 00128 // Special "operations" for emit 00129 SH_ARB_FUN 00130 }; 00131 00134 struct ArbOpInfo { 00135 char* name; 00136 int arity; 00137 bool collectingOp; 00138 }; 00139 00140 extern ArbOpInfo arbOpInfo[]; 00141 00144 struct ArbInst { 00145 static const int max_num_sources = 4; 00146 00147 ArbInst(ArbOp op, int label) 00148 : op(op), label(label), invert(false), 00149 update_cc(false), ccode(NOCC) 00150 { 00151 } 00152 00153 ArbInst(ArbOp op, int label, const SH::ShVariable& condition) 00154 : op(op), label(label), invert(false), 00155 update_cc(false), ccode(NOCC) 00156 { 00157 src[0] = condition; 00158 } 00159 00160 ArbInst(ArbOp op, const SH::ShVariable& dest) 00161 : op(op), dest(dest), invert(false), 00162 update_cc(false), ccode(NOCC) 00163 { 00164 } 00165 00166 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0) 00167 : op(op), dest(dest), invert(false), 00168 update_cc(false), ccode(NOCC) 00169 { 00170 src[0] = src0; 00171 } 00172 00173 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0, 00174 const SH::ShVariable& src1) 00175 : op(op), dest(dest), invert(false), 00176 update_cc(false), ccode(NOCC) 00177 { 00178 src[0] = src0; 00179 src[1] = src1; 00180 } 00181 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0, 00182 const SH::ShVariable& src1, const SH::ShVariable& src2) 00183 : op(op), dest(dest), invert(false), 00184 update_cc(false), ccode(NOCC) 00185 { 00186 src[0] = src0; 00187 src[1] = src1; 00188 src[2] = src2; 00189 } 00190 ArbInst(ArbOp op, const SH::ShVariable& dest, const SH::ShVariable& src0, 00191 const SH::ShVariable& src1, const SH::ShVariable& src2, 00192 const SH::ShVariable& src3) 00193 : op(op), dest(dest), invert(false), 00194 update_cc(false), ccode(NOCC) 00195 { 00196 src[0] = src0; 00197 src[1] = src1; 00198 src[2] = src2; 00199 src[3] = src3; 00200 } 00201 00202 ArbOp op; 00203 SH::ShVariable dest; 00204 00205 SH::ShVariable src[max_num_sources]; 00206 00207 int label; // For branching instructions and labels 00208 bool invert; // Invert the sense of a break condition. 00209 00210 // NV specific stuff for condition codes 00211 bool update_cc; 00212 00213 enum CCode { 00214 NOCC, 00215 EQ, 00216 GE, 00217 GT, 00218 LE, 00219 LT, 00220 NE, 00221 TR, 00222 FL 00223 } ccode; 00224 00225 SH::ShSwizzle ccswiz; 00226 00227 }; 00228 00229 extern char* arbCCnames[]; 00230 00231 } 00232 00233 #endif

Generated on Mon Oct 18 14:17:38 2004 for Sh by doxygen 1.3.7