-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[WIP] ABI Lowering Library #140112
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
Draft
vortex73
wants to merge
19
commits into
llvm:main
Choose a base branch
from
vortex73:abi
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.
Draft
[WIP] ABI Lowering Library #140112
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4d32f56
[LLVM ABI] The Typesystem
vortex73 8acd958
[LLVMABI] API for Creating types
vortex73 6fbc892
[LLVMABI] Mapper Interface
vortex73 22efa5f
[LLVMABI] QualType Mapper Implementation
vortex73 44b7a19
[LLVMABI] Added mappings for record types
vortex73 73dec0b
[LLVMABI] Support CXX classes with base classes
vortex73 581c618
[LLVMABI] Mapper Benchmark 1
vortex73 b2a4605
[LLVMABI] Refactor and Docs
vortex73 0f23942
[LLVMABI] Init ABIInfo
vortex73 733d5f3
[LLVMABI] Added BPF Target
vortex73 86c0574
[LLVMABI] Refactored the BPF Impl
vortex73 58e2070
[LLVMABI] clang integration
vortex73 235a1c9
[LLVMABI] Scaffolding the SysV ABI
vortex73 cfc0e13
[LLVMABI] Classifier
vortex73 0733721
[LLVMABI] Return Type Classifier
vortex73 c709adb
[LLVMABI] ReturnType Classifier Integration
vortex73 dc7e7f5
[LLVMABI] Argument+ReturnType classifiers
vortex73 2454dcf
[LLVMABI] The SysV ABI
vortex73 d8b8d84
[LLVMABI] Refactor
vortex73 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 hidden or 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,81 @@ | ||
| //==---- QualTypeMapper.h - Maps Clang QualType to LLVMABI Types -----------==// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// Maps Clang QualType instances to corresponding LLVM ABI type | ||
| /// representations. This mapper translates high-level type information from the | ||
| /// AST into low-level ABI-specific types that encode size, alignment, and | ||
| /// layout details required for code generation and cross-language | ||
| /// interoperability. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
| #ifndef CLANG_CODEGEN_QUALTYPE_MAPPER_H | ||
| #define CLANG_CODEGEN_QUALTYPE_MAPPER_H | ||
|
|
||
| #include "clang/AST/ASTContext.h" | ||
| #include "clang/AST/Decl.h" | ||
| #include "clang/AST/Type.h" | ||
| #include "clang/AST/TypeOrdering.h" | ||
| #include "llvm/ABI/Types.h" | ||
| #include "llvm/ADT/DenseMap.h" | ||
| #include "llvm/Support/Allocator.h" | ||
|
|
||
| namespace clang { | ||
| namespace CodeGen { | ||
|
|
||
| class QualTypeMapper { | ||
| private: | ||
| clang::ASTContext &ASTCtx; | ||
| llvm::abi::TypeBuilder Builder; | ||
|
|
||
| llvm::DenseMap<QualType, const llvm::abi::Type *> TypeCache; | ||
|
|
||
| const llvm::abi::Type *convertBuiltinType(const clang::BuiltinType *BT); | ||
| const llvm::abi::Type *convertPointerType(const clang::PointerType *PT); | ||
| const llvm::abi::Type *convertArrayType(const clang::ArrayType *AT); | ||
| const llvm::abi::Type *convertVectorType(const clang::VectorType *VT); | ||
| const llvm::abi::Type *convertRecordType(const clang::RecordType *RT); | ||
| const llvm::abi::Type *convertEnumType(const clang::EnumType *ET); | ||
| const llvm::abi::Type *convertReferenceType(const ReferenceType *RT); | ||
| const llvm::abi::Type *convertComplexType(const ComplexType *CT); | ||
| const llvm::abi::Type * | ||
| convertMemberPointerType(const clang::MemberPointerType *MPT); | ||
| const llvm::abi::Type *convertMatrixType(const ConstantMatrixType *MT); | ||
|
|
||
| const llvm::abi::RecordType *convertStructType(const clang::RecordDecl *RD); | ||
| const llvm::abi::RecordType *convertUnionType(const clang::RecordDecl *RD, | ||
| bool IsTransparent = false); | ||
| const llvm::abi::Type *createPointerTypeForPointee(QualType PointeeType); | ||
| const llvm::abi::RecordType *convertCXXRecordType(const CXXRecordDecl *RD, | ||
| bool CanPassInRegs); | ||
|
|
||
| void computeFieldInfo(const clang::RecordDecl *RD, | ||
| SmallVectorImpl<llvm::abi::FieldInfo> &Fields, | ||
| const clang::ASTRecordLayout &Layout); | ||
|
|
||
| llvm::TypeSize getTypeSize(clang::QualType QT) const; | ||
| llvm::Align getTypeAlign(clang::QualType QT) const; | ||
| llvm::Align getPreferredTypeAlign(QualType QT) const; | ||
| uint64_t getPointerSize() const; | ||
| uint64_t getPointerAlign() const; | ||
|
|
||
| public: | ||
| explicit QualTypeMapper(clang::ASTContext &Ctx, llvm::BumpPtrAllocator &Alloc) | ||
| : ASTCtx(Ctx), Builder(Alloc) {} | ||
|
|
||
| const llvm::abi::Type *convertType(clang::QualType QT); | ||
|
|
||
| void clearCache() { TypeCache.clear(); } | ||
|
|
||
| llvm::abi::TypeBuilder getTypeBuilder() { return Builder; } | ||
| }; | ||
|
|
||
| } // namespace CodeGen | ||
| } // namespace clang | ||
|
|
||
| #endif // CLANG_CODEGEN_QUALTYPE_MAPPER_H |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.