Path: blob/21.2-virgl/src/gallium/drivers/r300/compiler/radeon_program_pair.h
4574 views
/*1* Copyright (C) 2008 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_PROGRAM_PAIR_H_28#define __RADEON_PROGRAM_PAIR_H_2930#include "radeon_code.h"31#include "radeon_opcodes.h"32#include "radeon_program_constants.h"3334struct radeon_compiler;353637/**38* \file39* Represents a paired ALU instruction, as found in R300 and R50040* fragment programs.41*42* Note that this representation is taking some liberties as far43* as register files are concerned, to allow separate register44* allocation.45*46* Also note that there are some subtleties in that the semantics47* of certain opcodes are implicitly changed in this representation;48* see \ref rc_pair_translate49*/5051/* For rgb and alpha instructions when arg[n].Source = RC_PAIR_PRESUB_SRC, then52* the presubtract value will be used, and53* {RGB,Alpha}.Src[RC_PAIR_PRESUB_SRC].File will be set to RC_FILE_PRESUB.54*/55#define RC_PAIR_PRESUB_SRC 35657struct rc_pair_instruction_source {58unsigned int Used:1;59unsigned int File:4;60unsigned int Index:RC_REGISTER_INDEX_BITS;61};6263struct rc_pair_instruction_arg {64unsigned int Source:2;65unsigned int Swizzle:12;66unsigned int Abs:1;67unsigned int Negate:1;68};6970struct rc_pair_sub_instruction {71unsigned int Opcode:8;72unsigned int DestIndex:RC_REGISTER_INDEX_BITS;73unsigned int WriteMask:4;74unsigned int Target:2;75unsigned int OutputWriteMask:3;76unsigned int DepthWriteMask:1;77unsigned int Saturate:1;78unsigned int Omod:3;7980struct rc_pair_instruction_source Src[4];81struct rc_pair_instruction_arg Arg[3];82};8384struct rc_pair_instruction {85struct rc_pair_sub_instruction RGB;86struct rc_pair_sub_instruction Alpha;8788unsigned int WriteALUResult:2;89unsigned int ALUResultCompare:3;90unsigned int Nop:1;91unsigned int SemWait:1;92};9394typedef void (*rc_pair_foreach_src_fn)95(void *, struct rc_pair_instruction_source *);9697/**98* General helper functions for dealing with the paired instruction format.99*/100/*@{*/101int rc_pair_alloc_source(struct rc_pair_instruction *pair,102unsigned int rgb, unsigned int alpha,103rc_register_file file, unsigned int index);104105void rc_pair_foreach_source_that_alpha_reads(106struct rc_pair_instruction * pair,107void * data,108rc_pair_foreach_src_fn cb);109110void rc_pair_foreach_source_that_rgb_reads(111struct rc_pair_instruction * pair,112void * data,113rc_pair_foreach_src_fn cb);114115struct rc_pair_instruction_source * rc_pair_get_src(116struct rc_pair_instruction * pair_inst,117struct rc_pair_instruction_arg * arg);118119int rc_pair_get_src_index(120struct rc_pair_instruction * pair_inst,121struct rc_pair_instruction_source * src);122/*@}*/123124125/**126* Compiler passes that operate with the paired format.127*/128/*@{*/129struct radeon_pair_handler;130131void rc_pair_translate(struct radeon_compiler *cc, void *user);132void rc_pair_schedule(struct radeon_compiler *cc, void *user);133void rc_pair_regalloc(struct radeon_compiler *cc, void *user);134void rc_pair_remove_dead_sources(struct radeon_compiler *c, void *user);135/*@}*/136137#endif /* __RADEON_PROGRAM_PAIR_H_ */138139140