Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ARM compiling #134

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Code/max/Compiling/Configuration/Platform/Linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,30 @@
#if defined( __x86_64__ )
#define MAX_64BIT_WORD_SIZE
#define MAX_X86_64
#define MAX_LITTLE_ENDIAN
#elif defined( __i386__ )
#define MAX_32BIT_WORD_SIZE
#define MAX_X86
#define MAX_LITTLE_ENDIAN
#elif defined( __IA64__ )
#define MAX_64BIT_WORD_SIZE
#define MAX_IA64
#define MAX_LITTLE_ENDIAN
#elif defined( __aarch64__ )
#define MAX_64BIT_WORD_SIZE
#define MAX_AARCH64
#elif defined( __arm__ )
#define MAX_32BIT_WORD_SIZE
#define MAX_ARM
#elif defined( __thumb__ )
#define MAX_16BIT_WORD_SIZE
#define MAX_THUMB
#else
static_assert( false, "Unknown platform" );
#endif

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define MAX_LITTLE_ENDIAN
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define MAX_BIG_ENDIAN
#endif
#else
static_assert( false, "Unknown platform" );
#endif
Expand Down
7 changes: 7 additions & 0 deletions Code/max/Compiling/Configuration/Platform/Win32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
#define MAX_64BIT_WORD_SIZE
#define MAX_IA64
#define MAX_LITTLE_ENDIAN
#elif defined( _M_ARM )
#define MAX_32BIT_WORD_SIZE
#define MAX_ARM
#elif defined( _M_ARMT )
// Thumb mode
#define MAX_16BIT_WORD_SIZE
#define MAX_THUMB
#else
static_assert( false, "Unknown platform" );
#endif
Expand Down
8 changes: 7 additions & 1 deletion Code/max/Hardware/CPU/CPUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
#if defined( MAX_X86_64 )
#include <max/Hardware/CPU/IsCPUIDAvailablePolicies/X64GCCAssemblyIsCPUIDAvailablePolicy.hpp>
#include <max/Hardware/CPU/CPUIDPolicies/X64GCCAssemblyCPUIDPolicy.hpp>
#elif defined (MAX_X86 )
#elif defined( MAX_X86 )
#include <max/Hardware/CPU/IsCPUIDAvailablePolicies/X86GCCAssemblyIsCPUIDAvailablePolicy.hpp>
#include <max/Hardware/CPU/CPUIDPolicies/X86GCCAssemblyCPUIDPolicy.hpp>
#elif defined( MAX_AARCH64 ) || defined( MAX_ARM ) || defined( MAX_THUMB )
#include <max/Hardware/CPU/IsCPUIDAvailablePolicies/ArmIsCPUIDAvailablePolicy.hpp>
#include <max/Hardware/CPU/CPUIDPolicies/AArch64CPUIDPolicy.hpp>
#else
static_assert( false, "Unsupported platform" );
#endif
Expand Down Expand Up @@ -1285,6 +1288,9 @@ namespace CPU
#elif defined( MAX_X86 )
typedef X86GCCAssemblyIsCPUIDAvailablePolicy IsCPUIDAvailablePolicy;
typedef X86GCCAssemblyCPUIDPolicy CPUIDPolicy;
#elif defined( MAX_AARCH64 ) || defined( MAX_ARM ) || defined( MAX_THUMB )
typedef ArmIsCPUIDAvailablePolicy IsCPUIDAvailablePolicy;
typedef AArch64CPUIDPolicy CPUIDPolicy;
#else
static_assert( false, "Unsupported platform" );
#endif
Expand Down
21 changes: 21 additions & 0 deletions Code/max/Hardware/CPU/CPUIDPolicies/AArch64CPUIDPolicy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019, The max Contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <max/Hardware/CPU/CPUIDPolicies/AArch64CPUIDPolicy.hpp>

namespace max
{
namespace CPU
{

void AArch64CPUIDPolicy::CPUID( CPUIDSubleafResult & /*Registers*/, uint32_t /*Leaf*/ ) noexcept
{
}

void AArch64CPUIDPolicy::CPUIDExtended( CPUIDSubleafResult & /*Registers*/, uint32_t /*Leaf*/, uint32_t /*Subleaf*/ ) noexcept
{
}

} // namespace CPU
} // namespace max
29 changes: 29 additions & 0 deletions Code/max/Hardware/CPU/CPUIDPolicies/AArch64CPUIDPolicy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2019, The max Contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MAX_CPU_AARCH64CPUIDPOLICY_HPP
#define MAX_CPU_AARCH64CPUIDPOLICY_HPP

#include <array>
#include <cstdint>
#include "../CPUIDSubleafResult.hpp"

namespace max
{
namespace CPU
{

class AArch64CPUIDPolicy
{
public:

static void CPUID( CPUIDSubleafResult & Registers, uint32_t Leaf ) noexcept;
static void CPUIDExtended( CPUIDSubleafResult & Registers, uint32_t Leaf, uint32_t Subleaf ) noexcept;

};

} // namespace CPU
} // namespace max

#endif // #ifndef MAX_CPU_AARCH64CPUIDPOLICY_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2019, The max Contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MAX_CPUID_ARMISCPUIDAVAILABLEPOLICY_HPP
#define MAX_CPUID_ARMISCPUIDAVAILABLEPOLICY_HPP

namespace max
{
namespace CPU
{

class ArmIsCPUIDAvailablePolicy
{
public:

static bool IsCPUIDAvailable() noexcept { return true; }

};

} // namespace CPU
} // namespace max

#endif // #ifndef MAX_CPUID_ARMISCPUIDAVAILABLEPOLICY_HPP
2 changes: 1 addition & 1 deletion Docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ It includes common code such as logging, testing, abstractions for compiler and
* iOS*
* Instruction sets:
* x86 (64)
* ARM*
* ARM

*Coming soon

Expand Down
67 changes: 67 additions & 0 deletions Projects/Clang AArch64 Make/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
PROGRAM_NAME = max
CXX_SRCS = \
../../Code/max/Hardware/CPU/CPUIDPolicies/AArch64CPUIDPolicy.cpp \
../../Code/max/Hardware/CPU/Associativity.cpp \
../../Code/max/Hardware/CPU/CacheInfo.cpp \
../../Code/max/Hardware/CPU/CacheLevel.cpp \
../../Code/max/Hardware/CPU/CPUID.cpp \
../../Code/max/Hardware/CPU/CPUIDSubleafArgumentsAndResult.cpp \
../../Code/max/Hardware/CPU/Prefetch.cpp \
../../Code/max/Hardware/CPU/TLB.cpp \
../../Code/max/Hardware/CPU/TraceCache.cpp \
../../Code/max/Logging/DoNothingLogger.cpp \
../../Code/max/Testing/CoutResultPolicy.cpp
CXX_OBJS = $(CXX_SRCS:.cpp=.o)

INCLUDE_PATHS = \
../../Code
INCLUDE_PATHS_FLAGS = $(foreach d, $(INCLUDE_PATHS), -I$d)

LIBRARY_PATHS = \
.
LIBRARY_PATHS_FLAGS = $(foreach d, $(LIBRARY_PATHS), -L$d)

AUTOMATED_TEST_CXX_SRCS = \
../../Code/max/Algorithms/IsBetweenTest.cpp \
../../Code/max/Containers/Bits8Test.cpp \
../../Code/max/Containers/Bits16Test.cpp \
../../Code/max/Containers/Bits32Test.cpp \
../../Code/max/Containers/RangeTest.cpp \
../../Code/max/Containers/VectorTest.cpp \
../../Code/max/Testing/AutomatedTestsEntryPoint.cpp
AUTOMATED_TEST_CXX_OBJS = $(AUTOMATED_TEST_CXX_SRCS:.cpp=.o)

MANUAL_TEST_CXX_SRCS = \
../../Code/max/Compiling/AliasingOptimizationsTest.cpp \
../../Code/max/Compiling/ConfigurationTest.cpp \
../../Code/max/Testing/ManualTestsEntryPoint.cpp
MANUAL_TEST_CXX_OBJS = $(MANUAL_TEST_CXX_SRCS:.cpp=.o)

CPPFLAGS += $(INCLUDE_PATHS_FLAGS) -std=c++14 -Werror -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion
LINKER_FLAGS += $(LIBRARY_PATHS_FLAGS)




all: lib$(PROGRAM_NAME).a maxAutomatedTests maxManualTests

lib$(PROGRAM_NAME).a: $(PCH_OBJS) $(CXX_OBJS)
ar rcs lib$(PROGRAM_NAME).a $(CXX_OBJS)

maxAutomatedTests: $(AUTOMATED_TEST_CXX_OBJS)
clang++ -g $(AUTOMATED_TEST_CXX_OBJS) $(LINKER_FLAGS) -l$(PROGRAM_NAME) -o maxAutomatedTests

maxManualTests: $(MANUAL_TEST_CXX_OBJS)
clang++ -g $(MANUAL_TEST_CXX_OBJS) $(LINKER_FLAGS) -l$(PROGRAM_NAME) -o maxManualTests
.cpp.o:
clang++ -g $(CPPFLAGS) -c $< -o $@

clean:
@- $(RM) lib$(PROGRAM_NAME).a
@- $(RM) $(CXX_OBJS)
@- $(RM) maxAutomatedTests
@- $(RM) $(AUTOMATED_TEST_CXX_OBJS)
@- $(RM) maxManualTests
@- $(RM) $(MANUAL_TEST_CXX_OBJS)

distclean: clean