-
Notifications
You must be signed in to change notification settings - Fork 109
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
Loongarch Support #553
Open
SchrodingerZhu
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
SchrodingerZhu:loongarch-poc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Loongarch Support #553
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ namespace snmalloc | |
X86, | ||
X86_SGX, | ||
Sparc, | ||
RISCV | ||
RISCV, | ||
LoongArch | ||
}; | ||
} // namespace snmalloc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
|
||
#if __SIZEOF_POINTER__ == 8 | ||
# define SNMALLOC_VA_BITS_64 | ||
#else | ||
# define SNMALLOC_VA_BITS_32 | ||
#endif | ||
|
||
#include <cstddef> | ||
namespace snmalloc | ||
{ | ||
/** | ||
* Loongarch-specific architecture abstraction layer. | ||
*/ | ||
class AAL_LoongArch | ||
{ | ||
public: | ||
/** | ||
* Bitmap of AalFeature flags | ||
*/ | ||
static constexpr uint64_t aal_features = | ||
IntegerPointers | NoCpuCycleCounters; | ||
|
||
static constexpr enum AalName aal_name = LoongArch; | ||
|
||
static constexpr size_t smallest_page_size = 0x1000; | ||
|
||
/** | ||
* On pipelined processors, notify the core that we are in a spin loop and | ||
* that speculative execution past this point may not be a performance gain. | ||
*/ | ||
static inline void pause() | ||
{ | ||
__asm__ __volatile__("dbar 0" : : : "memory"); | ||
} | ||
|
||
/** | ||
* PRELD reads a cache-line of data from memory in advance into the Cache. | ||
* The access address is the 12bit immediate number of the value in the | ||
* general register rj plus the symbol extension. | ||
* | ||
* The processor learns from the hint in the PRELD instruction what type | ||
* will be acquired and which level of Cache the data to be taken back fill | ||
* in, hint has 32 optional values (0 to 31), 0 represents load to level 1 | ||
* Cache If the Cache attribute of the access address of the PRELD | ||
* instruction is not cached, then the instruction cannot generate a memory | ||
* access action and is treated as a NOP instruction. The PRELD instruction | ||
* will not trigger any exceptions related to MMU or address. | ||
*/ | ||
static inline void prefetch(void* ptr) | ||
{ | ||
__asm__ volatile("preld 0, %0, 0" : "=r"(ptr)); | ||
} | ||
}; | ||
|
||
using AAL_Arch = AAL_LoongArch; | ||
} // namespace snmalloc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should add an aal feature for non-4KiB-minimum-page-sizes and, if it's present, expose this as a size in the AAL. We could then have an
aal_minimum_page_size()
that returned 4KiB if you didn't set this feature and whatever size the AAL required if you did.