Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #74 from michaelwu/hexagon-fixes
Browse files Browse the repository at this point in the history
Fixes for the hexagon target
  • Loading branch information
alexcrichton authored and arielb1 committed Jun 27, 2017
2 parents b6b4e81 + 9394f96 commit 4948d77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/Target/Hexagon/HexagonISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,7 @@ static bool RetCC_Hexagon32(unsigned ValNo, MVT ValVT,
}
}

unsigned Offset = State.AllocateStack(4, 4);
State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
return false;
return true;
}

static bool RetCC_Hexagon64(unsigned ValNo, MVT ValVT,
Expand All @@ -500,9 +498,7 @@ static bool RetCC_Hexagon64(unsigned ValNo, MVT ValVT,
}
}

unsigned Offset = State.AllocateStack(8, 8);
State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
return false;
return true;
}

static bool RetCC_HexagonVector(unsigned ValNo, MVT ValVT,
Expand All @@ -513,7 +509,6 @@ static bool RetCC_HexagonVector(unsigned ValNo, MVT ValVT,
bool UseHVX = HST.useHVXOps();
bool UseHVXDbl = HST.useHVXDblOps();

unsigned OffSiz = 64;
if (LocVT == MVT::v16i32) {
if (unsigned Reg = State.AllocateReg(Hexagon::V0)) {
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
Expand All @@ -525,18 +520,14 @@ static bool RetCC_HexagonVector(unsigned ValNo, MVT ValVT,
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
return false;
}
OffSiz = 128;
} else if (LocVT == MVT::v64i32) {
if (unsigned Reg = State.AllocateReg(Hexagon::W0)) {
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
return false;
}
OffSiz = 256;
}

unsigned Offset = State.AllocateStack(OffSiz, OffSiz);
State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
return false;
return true;
}

void HexagonTargetLowering::promoteLdStType(MVT VT, MVT PromotedLdStVT) {
Expand Down Expand Up @@ -592,6 +583,16 @@ static bool isHvxVectorType(MVT Ty) {
}
}

bool
HexagonTargetLowering::CanLowerReturn(
CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg,
const SmallVectorImpl<ISD::OutputArg> &Outs,
LLVMContext &Context) const {
SmallVector<CCValAssign, 16> RVLocs;
CCState CCInfo(CallConv, isVarArg, MF, RVLocs, Context);
return CCInfo.CheckReturn(Outs, RetCC_Hexagon);
}

// LowerReturn - Lower ISD::RET. If a struct is larger than 8 bytes and is
// passed by value, the function prototype is modified to return void and
// the value is stored in memory pointed by a pointer passed by caller.
Expand Down Expand Up @@ -1234,7 +1235,7 @@ SDValue HexagonTargetLowering::LowerFormalArguments(
InVals.push_back(FIN);
} else {
InVals.push_back(
DAG.getLoad(VA.getLocVT(), dl, Chain, FIN, MachinePointerInfo()));
DAG.getLoad(VA.getValVT(), dl, Chain, FIN, MachinePointerInfo()));
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions lib/Target/Hexagon/HexagonISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ namespace HexagonISD {
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;

bool CanLowerReturn(CallingConv::ID CallConv,
MachineFunction &MF, bool isVarArg,
const SmallVectorImpl<ISD::OutputArg> &Outs,
LLVMContext &Context) const override;

SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
const SmallVectorImpl<ISD::OutputArg> &Outs,
const SmallVectorImpl<SDValue> &OutVals,
Expand Down

0 comments on commit 4948d77

Please sign in to comment.