mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 17:00:19 +02:00
In the event that the host doesn't support the requirements for running AVX-enabled applications (SVE2 with at least 256-bit wide vectors) but still wanted to run regular SSE-enabled applications, they would be taking a performance hit due to a load/store pessimization (necessary in order for 256-bit loads/stores to work) However, we can add an alternate view into the xmm data that would allow those hosts to use the previous optimization, while still supporting AVX-capable hosts.
104 lines
2.3 KiB
C++
104 lines
2.3 KiB
C++
/*
|
|
$info$
|
|
tags: ir|opts
|
|
$end_info$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <FEXCore/Config/Config.h>
|
|
#include <FEXCore/Utils/ThreadPoolAllocator.h>
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace FEXCore::HLE {
|
|
class SyscallHandler;
|
|
}
|
|
|
|
namespace FEXCore::IR {
|
|
class PassManager;
|
|
class IREmitter;
|
|
|
|
using ShouldExitHandler = std::function<void(void)>;
|
|
|
|
class Pass {
|
|
public:
|
|
virtual ~Pass() = default;
|
|
virtual bool Run(IREmitter *IREmit) = 0;
|
|
|
|
void RegisterPassManager(PassManager *_Manager) {
|
|
Manager = _Manager;
|
|
}
|
|
|
|
protected:
|
|
PassManager *Manager;
|
|
};
|
|
|
|
class PassManager final {
|
|
friend class SyscallOptimization;
|
|
public:
|
|
void AddDefaultPasses(FEXCore::Context::Context *ctx, bool InlineConstants, bool StaticRegisterAllocation);
|
|
void AddDefaultValidationPasses();
|
|
Pass* InsertPass(std::unique_ptr<Pass> Pass, std::string Name = "") {
|
|
Pass->RegisterPassManager(this);
|
|
auto PassPtr = Passes.emplace_back(std::move(Pass)).get();
|
|
|
|
if (!Name.empty()) {
|
|
NameToPassMaping[Name] = PassPtr;
|
|
}
|
|
return PassPtr;
|
|
}
|
|
|
|
void InsertRegisterAllocationPass(bool OptimizeSRA, bool SupportsAVX);
|
|
|
|
bool Run(IREmitter *IREmit);
|
|
|
|
void RegisterExitHandler(ShouldExitHandler Handler) {
|
|
ExitHandler = std::move(Handler);
|
|
}
|
|
|
|
bool HasPass(std::string Name) const {
|
|
return NameToPassMaping.contains(Name);
|
|
}
|
|
|
|
template<typename T>
|
|
T* GetPass(std::string Name) {
|
|
return dynamic_cast<T*>(NameToPassMaping[Name]);
|
|
}
|
|
|
|
Pass* GetPass(std::string Name) {
|
|
return NameToPassMaping[Name];
|
|
}
|
|
|
|
void RegisterSyscallHandler(FEXCore::HLE::SyscallHandler *Handler) {
|
|
SyscallHandler = Handler;
|
|
}
|
|
|
|
protected:
|
|
ShouldExitHandler ExitHandler;
|
|
FEXCore::HLE::SyscallHandler *SyscallHandler;
|
|
|
|
private:
|
|
std::vector<std::unique_ptr<Pass>> Passes;
|
|
std::unordered_map<std::string, Pass*> NameToPassMaping;
|
|
|
|
#if defined(ASSERTIONS_ENABLED) && ASSERTIONS_ENABLED
|
|
std::vector<std::unique_ptr<Pass>> ValidationPasses;
|
|
void InsertValidationPass(std::unique_ptr<Pass> Pass, std::string Name = "") {
|
|
Pass->RegisterPassManager(this);
|
|
auto PassPtr = ValidationPasses.emplace_back(std::move(Pass)).get();
|
|
|
|
if (!Name.empty()) {
|
|
NameToPassMaping[Name] = PassPtr;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE);
|
|
};
|
|
}
|
|
|