Path: blob/21.2-virgl/src/gallium/drivers/r300/compiler/radeon_opcodes.h
4574 views
/*1* Copyright (C) 2009 Nicolai Haehnle.2*3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining6* a copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sublicense, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial15* portions of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,18* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.20* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE21* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION22* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION23* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25*/2627#ifndef RADEON_OPCODES_H28#define RADEON_OPCODES_H2930#include <assert.h>3132/**33* Opcodes understood by the Radeon compiler.34*/35typedef enum {36RC_OPCODE_NOP = 0,37RC_OPCODE_ILLEGAL_OPCODE,3839/** vec4 instruction: dst.c = abs(src0.c); */40RC_OPCODE_ABS,4142/** vec4 instruction: dst.c = src0.c + src1.c; */43RC_OPCODE_ADD,4445/** special instruction: load address register46* dst.x = floor(src.x), where dst must be an address register */47RC_OPCODE_ARL,4849/** special instruction: load address register with round50* dst.x = round(src.x), where dst must be an address register */51RC_OPCODE_ARR,5253/** vec4 instruction: dst.c = ceil(src0.c) */54RC_OPCODE_CEIL,5556/** vec4 instruction: dst.c = clamp(src0.c, src1.c, src2.c) */57RC_OPCODE_CLAMP,5859/** vec4 instruction: dst.c = src0.c < 0.0 ? src1.c : src2.c */60RC_OPCODE_CMP,6162/** vec4 instruction: dst.c = src2.c > 0.5 ? src0.c : src1.c */63RC_OPCODE_CND,6465/** scalar instruction: dst = cos(src0.x) */66RC_OPCODE_COS,6768/** special instruction: take vec4 partial derivative in X direction69* dst.c = d src0.c / dx */70RC_OPCODE_DDX,7172/** special instruction: take vec4 partial derivative in Y direction73* dst.c = d src0.c / dy */74RC_OPCODE_DDY,7576/** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y */77RC_OPCODE_DP2,7879/** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z */80RC_OPCODE_DP3,8182/** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z + src0.w*src1.w */83RC_OPCODE_DP4,8485/** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z + src1.w */86RC_OPCODE_DPH,8788/** special instruction, see ARB_fragment_program */89RC_OPCODE_DST,9091/** scalar instruction: dst = 2**src0.x */92RC_OPCODE_EX2,9394/** special instruction, see ARB_vertex_program */95RC_OPCODE_EXP,9697/** vec4 instruction: dst.c = floor(src0.c) */98RC_OPCODE_FLR,99100/** vec4 instruction: dst.c = src0.c - floor(src0.c) */101RC_OPCODE_FRC,102103/** special instruction: stop execution if any component of src0 is negative */104RC_OPCODE_KIL,105106/** scalar instruction: dst = log_2(src0.x) */107RC_OPCODE_LG2,108109/** special instruction, see ARB_vertex_program */110RC_OPCODE_LIT,111112/** special instruction, see ARB_vertex_program */113RC_OPCODE_LOG,114115/** vec4 instruction: dst.c = src0.c*src1.c + (1 - src0.c)*src2.c */116RC_OPCODE_LRP,117118/** vec4 instruction: dst.c = src0.c*src1.c + src2.c */119RC_OPCODE_MAD,120121/** vec4 instruction: dst.c = max(src0.c, src1.c) */122RC_OPCODE_MAX,123124/** vec4 instruction: dst.c = min(src0.c, src1.c) */125RC_OPCODE_MIN,126127/** vec4 instruction: dst.c = src0.c */128RC_OPCODE_MOV,129130/** vec4 instruction: dst.c = src0.c*src1.c */131RC_OPCODE_MUL,132133/** scalar instruction: dst = src0.x ** src1.x */134RC_OPCODE_POW,135136/** scalar instruction: dst = 1 / src0.x */137RC_OPCODE_RCP,138139/** vec4 instruction: dst.c = floor(src0.c + 0.5) */140RC_OPCODE_ROUND,141142/** scalar instruction: dst = 1 / sqrt(src0.x) */143RC_OPCODE_RSQ,144145/** special instruction, see ARB_fragment_program */146RC_OPCODE_SCS,147148/** vec4 instruction: dst.c = (src0.c == src1.c) ? 1.0 : 0.0 */149RC_OPCODE_SEQ,150151/** vec4 instruction: dst.c = 0.0 */152RC_OPCODE_SFL,153154/** vec4 instruction: dst.c = (src0.c >= src1.c) ? 1.0 : 0.0 */155RC_OPCODE_SGE,156157/** vec4 instruction: dst.c = (src0.c > src1.c) ? 1.0 : 0.0 */158RC_OPCODE_SGT,159160/** scalar instruction: dst = sin(src0.x) */161RC_OPCODE_SIN,162163/** vec4 instruction: dst.c = (src0.c <= src1.c) ? 1.0 : 0.0 */164RC_OPCODE_SLE,165166/** vec4 instruction: dst.c = (src0.c < src1.c) ? 1.0 : 0.0 */167RC_OPCODE_SLT,168169/** vec4 instruction: dst.c = (src0.c != src1.c) ? 1.0 : 0.0 */170RC_OPCODE_SNE,171172/** vec4 instruction: dst.c = (src0.c < 0 ?) -1 : ((src0.c > 0) : 1 : 0) */173RC_OPCODE_SSG,174175/** vec4 instruction: dst.c = src0.c - src1.c */176RC_OPCODE_SUB,177178/** vec4 instruction: dst.c = src0.c */179RC_OPCODE_SWZ,180181/** vec4 instruction: dst.c = (abs(src0.c) - fract(abs(src0.c))) * sgn(src0.c) */182RC_OPCODE_TRUNC,183184/** special instruction, see ARB_fragment_program */185RC_OPCODE_XPD,186187RC_OPCODE_TEX,188RC_OPCODE_TXB,189RC_OPCODE_TXD,190RC_OPCODE_TXL,191RC_OPCODE_TXP,192193/** branch instruction:194* If src0.x != 0.0, continue with the next instruction;195* otherwise, jump to matching RC_OPCODE_ELSE or RC_OPCODE_ENDIF.196*/197RC_OPCODE_IF,198199/** branch instruction: jump to matching RC_OPCODE_ENDIF */200RC_OPCODE_ELSE,201202/** branch instruction: has no effect */203RC_OPCODE_ENDIF,204205RC_OPCODE_BGNLOOP,206207RC_OPCODE_BRK,208209RC_OPCODE_ENDLOOP,210211RC_OPCODE_CONT,212213/** special instruction, used in R300-R500 fragment program pair instructions214* indicates that the result of the alpha operation shall be replicated215* across all other channels */216RC_OPCODE_REPL_ALPHA,217218/** special instruction, used in R300-R500 fragment programs219* to indicate the start of a block of texture instructions that220* can run simultaneously. */221RC_OPCODE_BEGIN_TEX,222223/** Stop execution of the shader (GLSL discard) */224RC_OPCODE_KILP,225226/* Vertex shader CF Instructions */227RC_ME_PRED_SEQ,228RC_ME_PRED_SGT,229RC_ME_PRED_SGE,230RC_ME_PRED_SNEQ,231RC_ME_PRED_SET_CLR,232RC_ME_PRED_SET_INV,233RC_ME_PRED_SET_POP,234RC_ME_PRED_SET_RESTORE,235236RC_VE_PRED_SEQ_PUSH,237RC_VE_PRED_SGT_PUSH,238RC_VE_PRED_SGE_PUSH,239RC_VE_PRED_SNEQ_PUSH,240241MAX_RC_OPCODE242} rc_opcode;243244245struct rc_opcode_info {246rc_opcode Opcode;247const char * Name;248249/** true if the instruction reads from a texture.250*251* \note This is false for the KIL instruction, even though KIL is252* a texture instruction from a hardware point of view. */253unsigned int HasTexture:1;254255unsigned int NumSrcRegs:2;256unsigned int HasDstReg:1;257258/** true if this instruction affects control flow */259unsigned int IsFlowControl:1;260261/** true if this is a vector instruction that operates on components in parallel262* without any cross-component interaction */263unsigned int IsComponentwise:1;264265/** true if this instruction sources only its operands X components266* to compute one result which is smeared across all output channels */267unsigned int IsStandardScalar:1;268};269270extern struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE];271272static inline const struct rc_opcode_info * rc_get_opcode_info(rc_opcode opcode)273{274assert((unsigned int)opcode < MAX_RC_OPCODE);275assert(rc_opcodes[opcode].Opcode == opcode);276277return &rc_opcodes[opcode];278}279280struct rc_instruction;281282void rc_compute_sources_for_writemask(283const struct rc_instruction *inst,284unsigned int writemask,285unsigned int *srcmasks);286287#endif /* RADEON_OPCODES_H */288289290