aboutsummaryrefslogtreecommitdiff
path: root/source/opt/ir_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/opt/ir_context.h')
-rw-r--r--source/opt/ir_context.h81
1 files changed, 16 insertions, 65 deletions
diff --git a/source/opt/ir_context.h b/source/opt/ir_context.h
index 35075de1..2f27942b 100644
--- a/source/opt/ir_context.h
+++ b/source/opt/ir_context.h
@@ -35,7 +35,6 @@
#include "source/opt/dominator_analysis.h"
#include "source/opt/feature_manager.h"
#include "source/opt/fold.h"
-#include "source/opt/liveness.h"
#include "source/opt/loop_descriptor.h"
#include "source/opt/module.h"
#include "source/opt/register_pressure.h"
@@ -82,7 +81,6 @@ class IRContext {
kAnalysisConstants = 1 << 14,
kAnalysisTypes = 1 << 15,
kAnalysisDebugInfo = 1 << 16,
- kAnalysisLiveness = 1 << 17,
kAnalysisEnd = 1 << 17
};
@@ -203,7 +201,7 @@ class IRContext {
inline IteratorRange<Module::const_inst_iterator> ext_inst_debuginfo() const;
// Add |capability| to the module, if it is not already enabled.
- inline void AddCapability(spv::Capability capability);
+ inline void AddCapability(SpvCapability capability);
// Appends a capability instruction to this module.
inline void AddCapability(std::unique_ptr<Instruction>&& c);
@@ -250,15 +248,6 @@ class IRContext {
return def_use_mgr_.get();
}
- // Returns a pointer to a liveness manager. If the liveness manager is
- // invalid, it is rebuilt first.
- analysis::LivenessManager* get_liveness_mgr() {
- if (!AreAnalysesValid(kAnalysisLiveness)) {
- BuildLivenessManager();
- }
- return liveness_mgr_.get();
- }
-
// Returns a pointer to a value number table. If the liveness analysis is
// invalid, it is rebuilt first.
ValueNumberTable* GetValueNumberTable() {
@@ -378,11 +367,6 @@ class IRContext {
// having more than one name. This method returns the first one it finds.
inline Instruction* GetMemberName(uint32_t struct_type_id, uint32_t index);
- // Copy names from |old_id| to |new_id|. Only copy member name if index is
- // less than |max_member_index|.
- inline void CloneNames(const uint32_t old_id, const uint32_t new_id,
- const uint32_t max_member_index = UINT32_MAX);
-
// Sets the message consumer to the given |consumer|. |consumer| which will be
// invoked every time there is a message to be communicated to the outside.
void SetMessageConsumer(MessageConsumer c) { consumer_ = std::move(c); }
@@ -491,14 +475,14 @@ class IRContext {
if (!AreAnalysesValid(kAnalysisCombinators)) {
InitializeCombinators();
}
- constexpr uint32_t kExtInstSetIdInIndx = 0;
- constexpr uint32_t kExtInstInstructionInIndx = 1;
+ const uint32_t kExtInstSetIdInIndx = 0;
+ const uint32_t kExtInstInstructionInIndx = 1;
- if (inst->opcode() != spv::Op::OpExtInst) {
- return combinator_ops_[0].count(uint32_t(inst->opcode())) != 0;
+ if (inst->opcode() != SpvOpExtInst) {
+ return combinator_ops_[0].count(inst->opcode()) != 0;
} else {
uint32_t set = inst->GetSingleWordInOperand(kExtInstSetIdInIndx);
- auto op = inst->GetSingleWordInOperand(kExtInstInstructionInIndx);
+ uint32_t op = inst->GetSingleWordInOperand(kExtInstInstructionInIndx);
return combinator_ops_[set].count(op) != 0;
}
}
@@ -607,7 +591,7 @@ class IRContext {
}
Function* GetFunction(Instruction* inst) {
- if (inst->opcode() != spv::Op::OpFunction) {
+ if (inst->opcode() != SpvOpFunction) {
return nullptr;
}
return GetFunction(inst->result_id());
@@ -641,10 +625,6 @@ class IRContext {
// the function that contains |bb|.
bool IsReachable(const opt::BasicBlock& bb);
- // Return the stage of the module. Will generate error if entry points don't
- // all have the same stage.
- spv::ExecutionModel GetStage();
-
private:
// Builds the def-use manager from scratch, even if it was already valid.
void BuildDefUseManager() {
@@ -652,12 +632,6 @@ class IRContext {
valid_analyses_ = valid_analyses_ | kAnalysisDefUse;
}
- // Builds the liveness manager from scratch, even if it was already valid.
- void BuildLivenessManager() {
- liveness_mgr_ = MakeUnique<analysis::LivenessManager>(this);
- valid_analyses_ = valid_analyses_ | kAnalysisLiveness;
- }
-
// Builds the instruction-block map for the whole module.
void BuildInstrToBlockMapping() {
instr_to_block_.clear();
@@ -878,9 +852,6 @@ class IRContext {
std::unique_ptr<StructuredCFGAnalysis> struct_cfg_analysis_;
- // The liveness manager for |module_|.
- std::unique_ptr<analysis::LivenessManager> liveness_mgr_;
-
// The maximum legal value for the id bound.
uint32_t max_id_bound_;
@@ -1043,10 +1014,10 @@ IteratorRange<Module::const_inst_iterator> IRContext::ext_inst_debuginfo()
return ((const Module*)module_.get())->ext_inst_debuginfo();
}
-void IRContext::AddCapability(spv::Capability capability) {
+void IRContext::AddCapability(SpvCapability capability) {
if (!get_feature_mgr()->HasCapability(capability)) {
std::unique_ptr<Instruction> capability_inst(new Instruction(
- this, spv::Op::OpCapability, 0, 0,
+ this, SpvOpCapability, 0, 0,
{{SPV_OPERAND_TYPE_CAPABILITY, {static_cast<uint32_t>(capability)}}}));
AddCapability(std::move(capability_inst));
}
@@ -1056,7 +1027,7 @@ void IRContext::AddCapability(std::unique_ptr<Instruction>&& c) {
AddCombinatorsForCapability(c->GetSingleWordInOperand(0));
if (feature_mgr_ != nullptr) {
feature_mgr_->AddCapability(
- static_cast<spv::Capability>(c->GetSingleWordInOperand(0)));
+ static_cast<SpvCapability>(c->GetSingleWordInOperand(0)));
}
if (AreAnalysesValid(kAnalysisDefUse)) {
get_def_use_mgr()->AnalyzeInstDefUse(c.get());
@@ -1067,7 +1038,7 @@ void IRContext::AddCapability(std::unique_ptr<Instruction>&& c) {
void IRContext::AddExtension(const std::string& ext_name) {
std::vector<uint32_t> ext_words = spvtools::utils::MakeVector(ext_name);
AddExtension(std::unique_ptr<Instruction>(
- new Instruction(this, spv::Op::OpExtension, 0u, 0u,
+ new Instruction(this, SpvOpExtension, 0u, 0u,
{{SPV_OPERAND_TYPE_LITERAL_STRING, ext_words}})));
}
@@ -1084,7 +1055,7 @@ void IRContext::AddExtension(std::unique_ptr<Instruction>&& e) {
void IRContext::AddExtInstImport(const std::string& name) {
std::vector<uint32_t> ext_words = spvtools::utils::MakeVector(name);
AddExtInstImport(std::unique_ptr<Instruction>(
- new Instruction(this, spv::Op::OpExtInstImport, 0u, TakeNextId(),
+ new Instruction(this, SpvOpExtInstImport, 0u, TakeNextId(),
{{SPV_OPERAND_TYPE_LITERAL_STRING, ext_words}})));
}
@@ -1117,8 +1088,7 @@ void IRContext::AddDebug1Inst(std::unique_ptr<Instruction>&& d) {
void IRContext::AddDebug2Inst(std::unique_ptr<Instruction>&& d) {
if (AreAnalysesValid(kAnalysisNameMap)) {
- if (d->opcode() == spv::Op::OpName ||
- d->opcode() == spv::Op::OpMemberName) {
+ if (d->opcode() == SpvOpName || d->opcode() == SpvOpMemberName) {
// OpName and OpMemberName do not have result-ids. The target of the
// instruction is at InOperand index 0.
id_to_name_->insert({d->GetSingleWordInOperand(0), d.get()});
@@ -1181,8 +1151,8 @@ void IRContext::UpdateDefUse(Instruction* inst) {
void IRContext::BuildIdToNameMap() {
id_to_name_ = MakeUnique<std::multimap<uint32_t, Instruction*>>();
for (Instruction& debug_inst : debugs2()) {
- if (debug_inst.opcode() == spv::Op::OpMemberName ||
- debug_inst.opcode() == spv::Op::OpName) {
+ if (debug_inst.opcode() == SpvOpMemberName ||
+ debug_inst.opcode() == SpvOpName) {
id_to_name_->insert({debug_inst.GetSingleWordInOperand(0), &debug_inst});
}
}
@@ -1205,7 +1175,7 @@ Instruction* IRContext::GetMemberName(uint32_t struct_type_id, uint32_t index) {
auto result = id_to_name_->equal_range(struct_type_id);
for (auto i = result.first; i != result.second; ++i) {
auto* name_instr = i->second;
- if (name_instr->opcode() == spv::Op::OpMemberName &&
+ if (name_instr->opcode() == SpvOpMemberName &&
name_instr->GetSingleWordInOperand(1) == index) {
return name_instr;
}
@@ -1213,25 +1183,6 @@ Instruction* IRContext::GetMemberName(uint32_t struct_type_id, uint32_t index) {
return nullptr;
}
-void IRContext::CloneNames(const uint32_t old_id, const uint32_t new_id,
- const uint32_t max_member_index) {
- std::vector<std::unique_ptr<Instruction>> names_to_add;
- auto names = GetNames(old_id);
- for (auto n : names) {
- Instruction* old_name_inst = n.second;
- if (old_name_inst->opcode() == spv::Op::OpMemberName) {
- auto midx = old_name_inst->GetSingleWordInOperand(1);
- if (midx >= max_member_index) continue;
- }
- std::unique_ptr<Instruction> new_name_inst(old_name_inst->Clone(this));
- new_name_inst->SetInOperand(0, {new_id});
- names_to_add.push_back(std::move(new_name_inst));
- }
- // We can't add the new names when we are iterating over name range above.
- // We can add all the new names now.
- for (auto& new_name : names_to_add) AddDebug2Inst(std::move(new_name));
-}
-
} // namespace opt
} // namespace spvtools