3
* Copyright (c) 2018-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
#ifndef sfn_r600_instr_h
28
#define sfn_r600_instr_h
30
#include "sfn_instructionvisitor.h"
31
#include "sfn_value_gpr.h"
32
#include "sfn_defines.h"
34
#include "gallium/drivers/r600/r600_isa.h"
42
struct rename_reg_pair {
48
class LiverangeEvaluator;
54
ValueRemapper(std::vector<rename_reg_pair>& m,
57
void remap(PValue& v);
58
void remap(GPRVector& v);
60
PValue remap_one_registers(PValue& reg);
62
std::vector<rename_reg_pair>& m_map;
67
using OutputRegisterMap = std::map<unsigned, const GPRVector *>;
99
typedef std::shared_ptr<Instruction> Pointer;
101
friend bool operator == (const Instruction& lhs, const Instruction& rhs);
103
Instruction(instr_type t);
105
virtual ~Instruction();
107
instr_type type() const { return m_type;}
109
void print(std::ostream& os) const;
111
virtual void replace_values(const ValueSet& candidates, PValue new_value);
113
void evalue_liveness(LiverangeEvaluator& eval) const;
115
void remap_registers(ValueRemapper& map);
117
virtual bool accept(InstructionVisitor& visitor) = 0;
118
virtual bool accept(ConstInstructionVisitor& visitor) const = 0;
122
void add_remappable_src_value(PValue *v);
123
void add_remappable_src_value(GPRVector *v);
124
void add_remappable_dst_value(PValue *v);
125
void add_remappable_dst_value(GPRVector *v);
129
virtual void do_evalue_liveness(LiverangeEvaluator& eval) const;
131
virtual bool is_equal_to(const Instruction& lhs) const = 0;
135
virtual void do_print(std::ostream& os) const = 0;
137
std::vector<PValue*> m_mappable_src_registers;
138
std::vector<GPRVector*> m_mappable_src_vectors;
139
std::vector<PValue*> m_mappable_dst_registers;
140
std::vector<GPRVector*> m_mappable_dst_vectors;
143
using PInstruction=Instruction::Pointer;
145
inline std::ostream& operator << (std::ostream& os, const Instruction& instr)
151
bool operator == (const Instruction& lhs, const Instruction& rhs);