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

Avoid alignment for bls12381 vectors of 2-4 length #100

Merged
merged 1 commit into from
Jan 5, 2024
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
9 changes: 6 additions & 3 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2006,9 +2006,12 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {

// If the alignment is not a power of 2, round up to the next power of 2.
// This happens for non-power-of-2 length vectors.
if (Align & (Align-1)) {
Align = llvm::bit_ceil(Align);
Width = llvm::alignTo(Width, Align);
// (except of assigner target, we do not use alignment for it)
if (Target->getTriple().getArch() != llvm::Triple::assigner) {
if (Align & (Align-1)) {
Align = llvm::bit_ceil(Align);
Width = llvm::alignTo(Width, Align);
}
}
// Adjust the alignment based on the target max.
uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Basic/Targets/Assigner.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class LLVM_LIBRARY_VISIBILITY AssignerTargetInfo : public TargetInfo {
: TargetInfo(Triple) {
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
RegParmMax = 255;
// copied from x64_86:
resetDataLayout("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128");
// based on x64_86:
resetDataLayout("e-m:e-p270:32:32-p271:32:32-p272:64:64-v768:8-v1152:8-"
"v1536:8-i64:64-f80:128-n8:16:32:64-S128");
MaxAtomicPromoteWidth = 64;
MaxAtomicInlineWidth = 64;
MaxVectorAlign = 8;
}

void getTargetDefines(const LangOptions &Opts,
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Target/Assigner/AssignerTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAssignerTarget() {

static std::string computeDataLayout(const Triple &TT) {
assert(TT.getArch() == Triple::assigner);
// copied from x64_86:
return "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128";
// based on x64_86:
return "e-m:e-p270:32:32-p271:32:32-p272:64:64-v768:8-v1152:8-v1536:8-i64:64-"
"f80:128-n8:16:32:64-S128";
}

static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM) {
Expand Down