2 * Copyright 2011-2012 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
29 * @author Tom Stellard <thomas.stellard@amd.com>
34 #ifndef LP_BLD_TGSI_ACTION_H
35 #define LP_BLD_TGSI_ACTION_H
37 #include <llvm-c/Core.h>
39 struct lp_build_tgsi_context
;
41 struct lp_build_emit_data
{
42 /** Arguments that are passed to lp_build_tgsi_action::emit. The
43 * order of the arguments should be as follows:
44 * SOA: s0.x, s0.y, s0.z, s0.w, s1.x, s1.y, s1.z, s1.w, s2.x, s2.y, s2.x, s2.w
45 * AOS: s0.xyzw, s1.xyzw, s2.xyzw
46 * TEXTURE Instructions: coord.xyzw
48 * Arguments should be packed into the args array. For example an SOA
49 * instructions that reads s0.x and s1.x args should look like this:
53 LLVMValueRef args
[12];
56 * Number of arguments in the args array.
61 * The type output type of the opcode. This should be set in the
62 * lp_build_tgsi_action::fetch_args function.
66 /** This is used by the lp_build_tgsi_action::fetch_args function to
67 * determine which channel to read from the opcode arguments. It also
68 * specifies which index of the output array should be written to by
69 * the lp_build_tgsi_action::emit function. However, this value is
70 * usually ignored by any opcodes that are not TGSI_OUTPUT_COMPONENTWISE.
74 /** The lp_build_tgsi_action::emit 'executes' the opcode and writes the
75 * results to this array.
77 LLVMValueRef output
[4];
80 * The current instruction that is being 'executed'.
82 const struct tgsi_full_instruction
* inst
;
83 const struct tgsi_opcode_info
* info
;
86 struct lp_build_tgsi_action
90 * This function is responsible for doing 2-3 things:
91 * 1. Fetching the instruction arguments into the emit_data->args array.
92 * 2. Setting the number of arguments in emit_data->arg_count.
93 * 3. Setting the destination type in emit_data->dst_type (usually only
94 * necessary for opcodes that are TGSI_OUTPUT_COMPONENTWISE).
96 void (*fetch_args
)(struct lp_build_tgsi_context
*,
97 struct lp_build_emit_data
*);
101 * This function is responsible for emitting LLVM IR for a TGSI opcode.
102 * It should store the values it generates in the emit_data->output array
103 * and for TGSI_OUTPUT_COMPONENTWISE and TGSI_OUTPUT_REPLICATE instructions
104 * (and possibly others depending on the specific implementation), it should
105 * make sure to store the values in the array slot indexed by emit_data->chan.
107 void (*emit
)(const struct lp_build_tgsi_action
*,
108 struct lp_build_tgsi_context
*,
109 struct lp_build_emit_data
*);
112 * This variable can be used to store an intrinsic name, in case the TGSI
113 * opcode will be replaced by a target specific intrinsic. (There is a
114 * convenience function in lp_bld_tgsi.c called lp_build_tgsi_intrinsic()
115 * that can be assigned to lp_build_tgsi_action::emit and used for
116 * generating intrinsics).
118 const char * intr_name
;
122 * This function initializes the bld_base->op_actions array with some
123 * generic operand actions.
126 lp_set_default_actions(
127 struct lp_build_tgsi_context
* bld_base
);
130 * This function initialize the bld_base->op_actions array with some
131 * operand actions that are intended only for use when generating
132 * instructions to be executed on a CPU.
135 lp_set_default_actions_cpu(
136 struct lp_build_tgsi_context
* bld_base
);
138 #endif /* LP_BLD_TGSI_ACTION_H */