Skip to content

Commit

Permalink
[AIE2P] Legalization support for G_FADD/G_FSUB
Browse files Browse the repository at this point in the history
  • Loading branch information
katerynamuts committed Jan 30, 2025
1 parent 87f2b03 commit ed34d7c
Show file tree
Hide file tree
Showing 4 changed files with 567 additions and 16 deletions.
42 changes: 41 additions & 1 deletion llvm/lib/Target/AIE/aie2p/AIE2PLegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,22 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST)
getActionDefinitionsBuilder(G_FABS).customFor({S16, S32, S64}).scalarize(0);

getActionDefinitionsBuilder({G_FADD, G_FSUB})
.legalFor({V16S32})
.legalFor({AccV64S32})
.moreElementsIf(
[=](const LegalityQuery &Query) {
const LLT &Ty = Query.Types[0];

if (!Ty.isVector())
return false;

if (Ty.getElementType() != S32)
return false;

return Ty.getNumElements() != 64;
},
[=](const LegalityQuery &Query) {
return std::make_pair(0, LLT::fixed_vector(64, S32));
})
.customFor({S16})
.libcallFor({S32, S64});

Expand Down Expand Up @@ -547,6 +562,31 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST)
LLT::fixed_vector(SrcTy.getNumElements() / 2,
SrcTy.getElementType()));
})
.fewerElementsIf(
[=](const LegalityQuery &Query) {
const LLT &DstTy = Query.Types[0];
const LLT &SrcTy = Query.Types[1];

if (!SrcTy.isVector() || !DstTy.isVector())
return false;

// Unmerge of sources <= 32-bit are legalized into bit arithmetic
// below
if (SrcTy.getSizeInBits() <= 32)
return false;

// Unmerges into 2 subvectors are legal
if (DstTy.getSizeInBits() * 2 == SrcTy.getSizeInBits())
return false;

return true;
},
[=](const LegalityQuery &Query) {
const LLT &SrcTy = Query.Types[1];
return std::make_pair(1,
LLT::fixed_vector(SrcTy.getNumElements() / 2,
SrcTy.getElementType()));
})
.bitcastIf(
[=](const LegalityQuery &Query) {
const LLT &SrcTy = Query.Types[1];
Expand Down
Loading

0 comments on commit ed34d7c

Please sign in to comment.