2011-05-26 10:01:10 -07:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-05-03 10:55:50 -07:00
|
|
|
#include <stdint.h>
|
2011-05-02 09:45:40 -07:00
|
|
|
#include "brw_defines.h"
|
2014-02-19 18:38:40 -08:00
|
|
|
#include "brw_reg.h"
|
2014-02-19 18:37:11 -08:00
|
|
|
#include "main/compiler.h"
|
2011-10-26 13:51:28 -07:00
|
|
|
#include "glsl/ir.h"
|
2011-05-03 10:55:50 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-02-19 18:37:11 -08:00
|
|
|
enum PACKED register_file {
|
2013-04-29 16:05:05 -07:00
|
|
|
BAD_FILE,
|
|
|
|
GRF,
|
|
|
|
MRF,
|
|
|
|
IMM,
|
|
|
|
HW_REG, /* a struct brw_reg */
|
|
|
|
ATTR,
|
|
|
|
UNIFORM, /* prog_data->params[reg] */
|
|
|
|
};
|
|
|
|
|
2013-08-21 07:53:42 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2012-10-03 13:01:23 -07:00
|
|
|
class backend_instruction : public exec_node {
|
|
|
|
public:
|
2013-04-28 01:35:57 -07:00
|
|
|
bool is_tex();
|
|
|
|
bool is_math();
|
|
|
|
bool is_control_flow();
|
2013-09-19 19:48:22 -07:00
|
|
|
bool can_do_source_mods();
|
2013-12-11 23:07:49 -08:00
|
|
|
bool can_do_saturate();
|
2013-04-28 01:35:57 -07:00
|
|
|
|
2013-10-20 14:02:08 -07:00
|
|
|
/**
|
|
|
|
* True if the instruction has side effects other than writing to
|
|
|
|
* its destination registers. You are expected not to reorder or
|
|
|
|
* optimize these out unless you know what you are doing.
|
|
|
|
*/
|
|
|
|
bool has_side_effects() const;
|
|
|
|
|
2012-10-03 13:01:23 -07:00
|
|
|
enum opcode opcode; /* BRW_OPCODE_* or FS_OPCODE_* */
|
2012-10-03 13:23:05 -07:00
|
|
|
|
2014-02-19 17:21:16 -08:00
|
|
|
uint8_t predicate;
|
2012-10-03 13:23:05 -07:00
|
|
|
bool predicate_inverse;
|
2012-10-03 13:01:23 -07:00
|
|
|
};
|
|
|
|
|
2013-11-06 17:38:23 -08:00
|
|
|
enum instruction_scheduler_mode {
|
2013-11-19 13:07:12 -08:00
|
|
|
SCHEDULE_PRE,
|
2013-11-06 17:38:23 -08:00
|
|
|
SCHEDULE_PRE_NON_LIFO,
|
|
|
|
SCHEDULE_PRE_LIFO,
|
|
|
|
SCHEDULE_POST,
|
|
|
|
};
|
|
|
|
|
2012-10-03 13:01:23 -07:00
|
|
|
class backend_visitor : public ir_visitor {
|
|
|
|
public:
|
|
|
|
|
|
|
|
struct brw_context *brw;
|
|
|
|
struct gl_context *ctx;
|
|
|
|
struct brw_shader *shader;
|
2013-04-08 17:17:44 -07:00
|
|
|
struct gl_shader_program *shader_prog;
|
2013-10-03 10:30:07 -07:00
|
|
|
struct gl_program *prog;
|
2013-10-03 09:58:43 -07:00
|
|
|
struct brw_stage_prog_data *stage_prog_data;
|
2012-10-03 13:01:23 -07:00
|
|
|
|
|
|
|
/** ralloc context for temporary data used during compile */
|
|
|
|
void *mem_ctx;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of either fs_inst or vec4_instruction (inheriting from
|
|
|
|
* backend_instruction)
|
|
|
|
*/
|
|
|
|
exec_list instructions;
|
2013-04-29 14:21:14 -07:00
|
|
|
|
|
|
|
virtual void dump_instruction(backend_instruction *inst) = 0;
|
2013-08-04 23:34:01 -07:00
|
|
|
virtual void dump_instructions();
|
2013-10-03 09:58:43 -07:00
|
|
|
|
|
|
|
void assign_common_binding_table_offsets(uint32_t next_binding_table_offset);
|
2013-11-11 10:36:36 -08:00
|
|
|
|
|
|
|
virtual void invalidate_live_intervals() = 0;
|
2012-10-03 13:01:23 -07:00
|
|
|
};
|
|
|
|
|
2013-10-08 22:09:28 +13:00
|
|
|
uint32_t brw_texture_offset(struct gl_context *ctx, ir_constant *offset);
|
2013-08-21 07:53:42 -07:00
|
|
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2014-02-19 18:38:40 -08:00
|
|
|
enum brw_reg_type brw_type_for_base_type(const struct glsl_type *type);
|
2011-05-26 10:01:10 -07:00
|
|
|
uint32_t brw_conditional_for_comparison(unsigned int op);
|
2011-05-02 09:45:40 -07:00
|
|
|
uint32_t brw_math_function(enum opcode op);
|
2013-03-11 17:36:54 -07:00
|
|
|
const char *brw_instruction_name(enum opcode op);
|