-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add support for static symbols and GOT #60
Merged
Merged
Conversation
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 tests compilation of relocatable calls.
So far each label symbol (`TRLabelSymbol`) has been associated with block (`TRILBlock`). This commits relaxes this association - every label now may or may not be associated with block. This allows labels to be also used in "local control flows" (local meaning within one evaluator). It will also allow to unify labels with other symbol types (such as function symbols or statics). Technically, a `TRLabelSymbol` the association is still from symbol to block. I have tried to make it the other way round, from block to it's symbol, but that made code managing CFG bit ugly so I decided to keep it like this for time being.
Static symbols represent data stored on the heap (as opposed to data stored in frame which are represented by `TRRegisterMappedSymbol`s) and therefore have a single unique absolute address. The address however may not be known in advance so code individual code generators must always generate proper relocations when accessing static symbols. Jump labels and functions are special kind of static symbols.
This commit adds `TRTarget >> endian` which can be used by various parts when reading from / writing to (target) memory. As of now, both RISC-V and POWER targets are hard-coded as little endian even thought this is not always true. This may be fixes in the future. The rest of Tinyrossa code should consult `TRTarget >> endian` wherever necessary.
Commit b32bc8e added `TRDataType >> #sizeInBytes`. While it is convenient and looks like a good OO design, it does not really work. The size of `Address` (pointer) is architecture-dependent. This commit deprecates `TRDataType >> #sizeInBytes` in favour of `TRTarget >> sizeInBytesOf:` and updates users. Note, that `TRDataType >> #sizeInBytes` has been kept there as "should-not-implement" with comment to prevent future myself to make this tempting mistake again.
This commit adds support for GOT-based accesses (for loading / storing values from / to static symbols). This is implemented by handling `AcRelocationRequestGOTEntry`.
This commit changes `TRRV64GSystemLinkage` to compile relocatable calls using pair of `auipc` and `jalr` with `R_RISCV_CALL_PLT` relocation.
This commit implements loads and stores for static symbols using 32bit PC-relative addressing. In the future, we should use GOT access to allow static symbols to be located anywhere in address space, but this needs to wait for GOT (and PLT) support in code cache.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds support for static symbols and for loading/storing into them via GOT. This is implemented by handling
AcRelocationRequestGOTEntry
inTRCodeCache >> #link
. GOT entries are allocated from the "end" of the code cache.