Skip to content

Commit

Permalink
Avoid alignment for bls12381 vectors of 2-4 length
Browse files Browse the repository at this point in the history
  • Loading branch information
makxenov committed Jan 5, 2024
1 parent 48fd30c commit 80a8e0f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
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

0 comments on commit 80a8e0f

Please sign in to comment.