3
* Copyright (c) 2019 Collabora LTD
5
* Author: Gert Wollny <gert.wollny@collabora.com>
7
* Permission is hereby granted, free of charge, to any person obtaining a
8
* copy of this software and associated documentation files (the "Software"),
9
* to deal in the Software without restriction, including without limitation
10
* on the rights to use, copy, modify, merge, publish, distribute, sub
11
* license, and/or sell copies of the Software, and to permit persons to whom
12
* the Software is furnished to do so, subject to the following conditions:
14
* The above copyright notice and this permission notice (including the next
15
* paragraph) shall be included in all copies or substantial portions of the
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24
* USE OR OTHER DEALINGS IN THE SOFTWARE.
27
#include "sfn_emitinstruction.h"
29
#include "sfn_shader_base.h"
33
EmitInstruction::EmitInstruction(ShaderFromNirProcessor& processor):
39
EmitInstruction::~EmitInstruction()
43
bool EmitInstruction::emit(nir_instr* instr)
45
return do_emit(instr);
48
PValue EmitInstruction::from_nir(const nir_src& v, unsigned component, unsigned swizzled)
50
return m_proc.from_nir(v, component, swizzled);
53
PValue EmitInstruction::from_nir(const nir_alu_src& v, unsigned component)
55
return m_proc.from_nir(v, component);
58
PValue EmitInstruction::from_nir(const nir_tex_src& v, unsigned component)
60
return m_proc.from_nir(v, component);
63
PValue EmitInstruction::from_nir(const nir_alu_dest& v, unsigned component)
65
return m_proc.from_nir(v, component);
68
PValue EmitInstruction::from_nir(const nir_dest& v, unsigned component)
70
return m_proc.from_nir(v, component);
73
PValue EmitInstruction::from_nir(const nir_src& v, unsigned component)
75
return m_proc.from_nir(v, component);
78
void EmitInstruction::emit_instruction(Instruction *ir)
80
return m_proc.emit_instruction(ir);
83
void EmitInstruction::emit_instruction(AluInstruction *ir)
85
return m_proc.emit_instruction(ir);
88
bool EmitInstruction::emit_instruction(EAluOp opcode, PValue dest,
89
std::vector<PValue> src0,
90
const std::set<AluModifiers>& m_flags)
92
return m_proc.emit_instruction(opcode, dest,src0, m_flags);
96
EmitInstruction::get_deref_location(const nir_src& v) const
98
return m_proc.get_deref_location(v);
101
PValue EmitInstruction::from_nir_with_fetch_constant(const nir_src& src, unsigned component, int channel)
103
return m_proc.from_nir_with_fetch_constant(src, component, channel);
106
GPRVector EmitInstruction::vec_from_nir_with_fetch_constant(const nir_src& src, unsigned mask,
107
const GPRVector::Swizzle& swizzle, bool match)
109
return m_proc.vec_from_nir_with_fetch_constant(src, mask, swizzle, match);
112
PGPRValue EmitInstruction::get_temp_register(int channel)
114
return m_proc.get_temp_register(channel);
117
GPRVector EmitInstruction::get_temp_vec4(const GPRVector::Swizzle& swizzle)
119
return m_proc.get_temp_vec4(swizzle);
122
PValue EmitInstruction::create_register_from_nir_src(const nir_src& src, unsigned swizzle)
124
return m_proc.create_register_from_nir_src(src, swizzle);
127
enum chip_class EmitInstruction::get_chip_class(void) const
129
return m_proc.get_chip_class();
132
PValue EmitInstruction::literal(uint32_t value)
134
return m_proc.literal(value);
137
GPRVector EmitInstruction::vec_from_nir(const nir_dest& dst, int num_components)
139
return m_proc.vec_from_nir(dst, num_components);
142
bool EmitInstruction::inject_register(unsigned sel, unsigned swizzle,
143
const PValue& reg, bool map)
145
return m_proc.inject_register(sel, swizzle, reg, map);
148
int EmitInstruction::remap_atomic_base(int base)
150
return m_proc.remap_atomic_base(base);
153
void EmitInstruction::set_has_txs_cube_array_comp()
155
m_proc.sh_info().has_txq_cube_array_z_comp = 1;
158
const std::set<AluModifiers> EmitInstruction::empty = {};
159
const std::set<AluModifiers> EmitInstruction::write = {alu_write};
160
const std::set<AluModifiers> EmitInstruction::last_write = {alu_write, alu_last_instr};
161
const std::set<AluModifiers> EmitInstruction::last = {alu_last_instr};