remove unneeded dolphin code, C++11 static_assert

This commit is contained in:
RSDuck
2019-08-16 23:17:08 +02:00
parent dcf21c98f2
commit 5e443e7962
12 changed files with 41 additions and 216 deletions

View File

@ -1,91 +0,0 @@
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license_dolphin.txt file included.
#pragma once
#include <cstddef>
#include <vector>
#include "Assert.h"
#include "../types.h"
namespace Common
{
// Everything that needs to generate code should inherit from this.
// You get memory management for free, plus, you can use all emitter functions without
// having to prefix them with gen-> or something similar.
// Example implementation:
// class JIT : public CodeBlock<ARMXEmitter> {}
template <class T>
class CodeBlock : public T
{
private:
// A privately used function to set the executable RAM space to something invalid.
// For debugging usefulness it should be used to set the RAM to a host specific breakpoint
// instruction
virtual void PoisonMemory() = 0;
protected:
u8* region = nullptr;
// Size of region we can use.
size_t region_size = 0;
// Original size of the region we allocated.
size_t total_region_size = 0;
bool m_is_child = false;
std::vector<CodeBlock*> m_children;
public:
CodeBlock() = default;
virtual ~CodeBlock()
{
}
CodeBlock(const CodeBlock&) = delete;
CodeBlock& operator=(const CodeBlock&) = delete;
CodeBlock(CodeBlock&&) = delete;
CodeBlock& operator=(CodeBlock&&) = delete;
// Always clear code space with breakpoints, so that if someone accidentally executes
// uninitialized, it just breaks into the debugger.
void ClearCodeSpace()
{
PoisonMemory();
ResetCodePtr();
}
bool IsInSpace(const u8* ptr) const { return ptr >= region && ptr < (region + region_size); }
void ResetCodePtr() { T::SetCodePtr(region); }
size_t GetSpaceLeft() const
{
ASSERT(static_cast<size_t>(T::GetCodePtr() - region) < region_size);
return region_size - (T::GetCodePtr() - region);
}
bool IsAlmostFull() const
{
// This should be bigger than the biggest block ever.
return GetSpaceLeft() < 0x10000;
}
bool HasChildren() const { return region_size != total_region_size; }
u8* AllocChildCodeSpace(size_t child_size)
{
ASSERT_MSG(DYNA_REC, child_size < GetSpaceLeft(), "Insufficient space for child allocation.");
u8* child_region = region + region_size - child_size;
region_size -= child_size;
return child_region;
}
void AddChildCodeSpace(CodeBlock* child, size_t child_size)
{
u8* child_region = AllocChildCodeSpace(child_size);
child->m_is_child = true;
child->region = child_region;
child->region_size = child_size;
child->total_region_size = child_size;
child->ResetCodePtr();
m_children.emplace_back(child);
}
};
} // namespace Common

View File

@ -1,11 +1,9 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license_dolphin.txt file included.
// Stubs for Assert.h and Log.h
#pragma once
#include <assert.h>
// Assert stub
#define ASSERT_MSG(_t_, _a_, _fmt_, ...) \
assert(_a_) \
/*do \
@ -45,3 +43,21 @@
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) \
ASSERT(_a_); \
} while (0)*/
// Log Stub
#include <cstdio>
#define PanicAlert(fmt, ...) \
do \
{ \
printf(fmt "\n", ## __VA_ARGS__); \
abort(); \
} while (false)
#define DYNA_REC 0
#define ERROR_LOG(which, fmt, ...) \
do \
{ \
printf(fmt "\n", ## __VA_ARGS__); \
} while (false)

View File

@ -1,72 +0,0 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license_dolphin.txt file included.
#pragma once
#if defined(_M_X86)
/**
* It is assumed that all compilers used to build Dolphin support intrinsics up to and including
* SSE 4.2 on x86/x64.
*/
#if defined(__GNUC__) || defined(__clang__)
/**
* Due to limitations in GCC, SSE intrinsics are only available when compiling with the
* corresponding instruction set enabled. However, using the target attribute, we can compile
* single functions with a different target instruction set, while still creating a generic build.
*
* Since this instruction set is enabled per-function, any callers should verify that the
* instruction set is supported at runtime before calling it, and provide a fallback implementation
* when not supported.
*
* When building with -march=native, or enabling the instruction sets in the compile flags, permit
* usage of the instrinsics without any function attributes. If the command-line architecture does
* not support this instruction set, enable it via function targeting.
*/
#include <x86intrin.h>
#ifndef __SSE4_2__
#define FUNCTION_TARGET_SSE42 [[gnu::target("sse4.2")]]
#endif
#ifndef __SSE4_1__
#define FUNCTION_TARGET_SSR41 [[gnu::target("sse4.1")]]
#endif
#ifndef __SSSE3__
#define FUNCTION_TARGET_SSSE3 [[gnu::target("ssse3")]]
#endif
#ifndef __SSE3__
#define FUNCTION_TARGET_SSE3 [[gnu::target("sse3")]]
#endif
#elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
/**
* MSVC and ICC support intrinsics for any instruction set without any function attributes.
*/
#include <intrin.h>
#endif // defined(_MSC_VER) || defined(__INTEL_COMPILER)
#endif // _M_X86
/**
* Define the FUNCTION_TARGET macros to nothing if they are not needed, or not on an X86 platform.
* This way when a function is defined with FUNCTION_TARGET you don't need to define a second
* version without the macro around a #ifdef guard. Be careful when using intrinsics, as all use
* should still be placed around a #ifdef _M_X86 if the file is compiled on all architectures.
*/
#ifndef FUNCTION_TARGET_SSE42
#define FUNCTION_TARGET_SSE42
#endif
#ifndef FUNCTION_TARGET_SSR41
#define FUNCTION_TARGET_SSR41
#endif
#ifndef FUNCTION_TARGET_SSSE3
#define FUNCTION_TARGET_SSSE3
#endif
#ifndef FUNCTION_TARGET_SSE3
#define FUNCTION_TARGET_SSE3
#endif

View File

@ -1,21 +0,0 @@
#pragma once
#include "CommonFuncs.h"
#include <stdio.h>
#define PanicAlert(fmt, ...) \
do \
{ \
printf(fmt "\n", ## __VA_ARGS__); \
abort(); \
} while (false)
#define DYNA_REC 0
#define ERROR_LOG(which, fmt, ...) \
do \
{ \
printf(fmt "\n", ## __VA_ARGS__); \
} while (false)

View File

@ -7,7 +7,6 @@
#include "CPUDetect.h"
#include "../types.h"
#include "Intrinsics.h"
#ifndef _MSVC_VER

View File

@ -7,9 +7,10 @@
#include "CPUDetect.h"
#include "../types.h"
#include "Log.h"
#include "x64Emitter.h"
#include "x64Reg.h"
#include "Compat.h"
#include "CommonFuncs.h"
namespace Gen
{

View File

@ -12,9 +12,8 @@
#include <tuple>
#include <type_traits>
#include "Assert.h"
#include "Compat.h"
#include "BitSet.h"
#include "CodeBlock.h"
#include "../types.h"
#include "x64ABI.h"
@ -1167,14 +1166,4 @@ public:
}
}; // class XEmitter
class X64CodeBlock : public Common::CodeBlock<XEmitter>
{
private:
void PoisonMemory() override
{
// x86/64: 0xCC = breakpoint
memset(region, 0xCC, region_size);
}
};
} // namespace