mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
First chunk of actually generating vector code for packed types. These
changes allow us to generate the following code:
_foo:
li r2, 0
lvx v0, r2, r3
vaddfp v0, v0, v0
stvx v0, r2, r3
blr
for this llvm:
void %foo(<4 x float>* %a) {
entry:
%tmp1 = load <4 x float>* %a
%tmp2 = add <4 x float> %tmp1, %tmp1
store <4 x float> %tmp2, <4 x float>* %a
ret void
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24534 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -520,12 +520,19 @@ void SelectionDAGLowering::visitBinary(User &I, unsigned IntOp, unsigned FPOp,
|
||||
const PackedType *PTy = cast<PackedType>(Ty);
|
||||
unsigned NumElements = PTy->getNumElements();
|
||||
MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
|
||||
MVT::ValueType TVT = MVT::getVectorType(PVT, NumElements);
|
||||
|
||||
// Immediately scalarize packed types containing only one element, so that
|
||||
// the Legalize pass does not have to deal with them.
|
||||
// the Legalize pass does not have to deal with them. Similarly, if the
|
||||
// abstract vector is going to turn into one that the target natively
|
||||
// supports, generate that type now so that Legalize doesn't have to deal
|
||||
// with that either. These steps ensure that Legalize only has to handle
|
||||
// vector types in its Expand case.
|
||||
unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp;
|
||||
if (NumElements == 1) {
|
||||
unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp;
|
||||
setValue(&I, DAG.getNode(Opc, PVT, Op1, Op2));
|
||||
} else if (TVT != MVT::Other && TLI.isTypeLegal(TVT)) {
|
||||
setValue(&I, DAG.getNode(Opc, TVT, Op1, Op2));
|
||||
} else {
|
||||
SDOperand Num = DAG.getConstant(NumElements, MVT::i32);
|
||||
SDOperand Typ = DAG.getValueType(PVT);
|
||||
@@ -777,11 +784,14 @@ void SelectionDAGLowering::visitLoad(LoadInst &I) {
|
||||
const PackedType *PTy = cast<PackedType>(Ty);
|
||||
unsigned NumElements = PTy->getNumElements();
|
||||
MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
|
||||
MVT::ValueType TVT = MVT::getVectorType(PVT, NumElements);
|
||||
|
||||
// Immediately scalarize packed types containing only one element, so that
|
||||
// the Legalize pass does not have to deal with them.
|
||||
if (NumElements == 1) {
|
||||
L = DAG.getLoad(PVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0)));
|
||||
} else if (TVT != MVT::Other && TLI.isTypeLegal(TVT)) {
|
||||
L = DAG.getLoad(TVT, Root, Ptr, DAG.getSrcValue(I.getOperand(0)));
|
||||
} else {
|
||||
L = DAG.getVecLoad(NumElements, PVT, Root, Ptr,
|
||||
DAG.getSrcValue(I.getOperand(0)));
|
||||
|
||||
Reference in New Issue
Block a user