forked from OSchip/llvm-project
MSP430: Avoid using getPointerSize/getPointerTy
Use the contextually appropriate value instead of relying on the default address space default parameters. Usually you should be reusing a pre-existing type.
This commit is contained in:
parent
6d481adb35
commit
f942cde61a
|
@ -255,7 +255,7 @@ bool MSP430DAGToDAGISel::SelectAddr(SDValue N,
|
|||
Base = (AM.BaseType == MSP430ISelAddressMode::FrameIndexBase)
|
||||
? CurDAG->getTargetFrameIndex(
|
||||
AM.Base.FrameIndex,
|
||||
getTargetLowering()->getPointerTy(CurDAG->getDataLayout()))
|
||||
N.getValueType())
|
||||
: AM.Base.Reg;
|
||||
|
||||
if (AM.GV)
|
||||
|
|
|
@ -670,16 +670,17 @@ SDValue MSP430TargetLowering::LowerCCCArguments(
|
|||
InVals.push_back(ArgValue);
|
||||
}
|
||||
} else {
|
||||
// Only arguments passed on the stack should make it here.
|
||||
// Only arguments passed on the stack should make it here.
|
||||
assert(VA.isMemLoc());
|
||||
|
||||
SDValue InVal;
|
||||
ISD::ArgFlagsTy Flags = Ins[i].Flags;
|
||||
|
||||
if (Flags.isByVal()) {
|
||||
MVT PtrVT = VA.getLocVT();
|
||||
int FI = MFI.CreateFixedObject(Flags.getByValSize(),
|
||||
VA.getLocMemOffset(), true);
|
||||
InVal = DAG.getFrameIndex(FI, getPointerTy(DAG.getDataLayout()));
|
||||
InVal = DAG.getFrameIndex(FI, PtrVT);
|
||||
} else {
|
||||
// Load the argument to a virtual register
|
||||
unsigned ObjSize = VA.getLocVT().getSizeInBits()/8;
|
||||
|
@ -777,13 +778,14 @@ MSP430TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
|
|||
if (!Reg)
|
||||
llvm_unreachable("sret virtual register not created in entry block");
|
||||
|
||||
MVT PtrVT = getFrameIndexTy(DAG.getDataLayout());
|
||||
SDValue Val =
|
||||
DAG.getCopyFromReg(Chain, dl, Reg, getPointerTy(DAG.getDataLayout()));
|
||||
DAG.getCopyFromReg(Chain, dl, Reg, PtrVT);
|
||||
unsigned R12 = MSP430::R12;
|
||||
|
||||
Chain = DAG.getCopyToReg(Chain, dl, R12, Val, Flag);
|
||||
Flag = Chain.getValue(1);
|
||||
RetOps.push_back(DAG.getRegister(R12, getPointerTy(DAG.getDataLayout())));
|
||||
RetOps.push_back(DAG.getRegister(R12, PtrVT));
|
||||
}
|
||||
|
||||
unsigned Opc = (CallConv == CallingConv::MSP430_INTR ?
|
||||
|
@ -814,7 +816,7 @@ SDValue MSP430TargetLowering::LowerCCCCallTo(
|
|||
|
||||
// Get a count of how many bytes are to be pushed on the stack.
|
||||
unsigned NumBytes = CCInfo.getNextStackOffset();
|
||||
auto PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
MVT PtrVT = getFrameIndexTy(DAG.getDataLayout());
|
||||
|
||||
Chain = DAG.getCALLSEQ_START(Chain, NumBytes, 0, dl);
|
||||
|
||||
|
@ -1010,7 +1012,7 @@ SDValue MSP430TargetLowering::LowerGlobalAddress(SDValue Op,
|
|||
SelectionDAG &DAG) const {
|
||||
const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
|
||||
int64_t Offset = cast<GlobalAddressSDNode>(Op)->getOffset();
|
||||
auto PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
EVT PtrVT = Op.getValueType();
|
||||
|
||||
// Create the TargetGlobalAddress node, folding in the constant offset.
|
||||
SDValue Result = DAG.getTargetGlobalAddress(GV, SDLoc(Op), PtrVT, Offset);
|
||||
|
@ -1021,7 +1023,7 @@ SDValue MSP430TargetLowering::LowerExternalSymbol(SDValue Op,
|
|||
SelectionDAG &DAG) const {
|
||||
SDLoc dl(Op);
|
||||
const char *Sym = cast<ExternalSymbolSDNode>(Op)->getSymbol();
|
||||
auto PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
EVT PtrVT = Op.getValueType();
|
||||
SDValue Result = DAG.getTargetExternalSymbol(Sym, PtrVT);
|
||||
|
||||
return DAG.getNode(MSP430ISD::Wrapper, dl, PtrVT, Result);
|
||||
|
@ -1030,8 +1032,8 @@ SDValue MSP430TargetLowering::LowerExternalSymbol(SDValue Op,
|
|||
SDValue MSP430TargetLowering::LowerBlockAddress(SDValue Op,
|
||||
SelectionDAG &DAG) const {
|
||||
SDLoc dl(Op);
|
||||
auto PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
const BlockAddress *BA = cast<BlockAddressSDNode>(Op)->getBlockAddress();
|
||||
EVT PtrVT = Op.getValueType();
|
||||
SDValue Result = DAG.getTargetBlockAddress(BA, PtrVT);
|
||||
|
||||
return DAG.getNode(MSP430ISD::Wrapper, dl, PtrVT, Result);
|
||||
|
@ -1248,11 +1250,11 @@ MSP430TargetLowering::getReturnAddressFrameIndex(SelectionDAG &DAG) const {
|
|||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
MSP430MachineFunctionInfo *FuncInfo = MF.getInfo<MSP430MachineFunctionInfo>();
|
||||
int ReturnAddrIndex = FuncInfo->getRAIndex();
|
||||
auto PtrVT = getPointerTy(MF.getDataLayout());
|
||||
MVT PtrVT = getFrameIndexTy(MF.getDataLayout());
|
||||
|
||||
if (ReturnAddrIndex == 0) {
|
||||
// Set up a frame object for the return address.
|
||||
uint64_t SlotSize = MF.getDataLayout().getPointerSize();
|
||||
uint64_t SlotSize = PtrVT.getStoreSize();
|
||||
ReturnAddrIndex = MF.getFrameInfo().CreateFixedObject(SlotSize, -SlotSize,
|
||||
true);
|
||||
FuncInfo->setRAIndex(ReturnAddrIndex);
|
||||
|
@ -1271,12 +1273,12 @@ SDValue MSP430TargetLowering::LowerRETURNADDR(SDValue Op,
|
|||
|
||||
unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
|
||||
SDLoc dl(Op);
|
||||
auto PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
EVT PtrVT = Op.getValueType();
|
||||
|
||||
if (Depth > 0) {
|
||||
SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
|
||||
SDValue Offset =
|
||||
DAG.getConstant(DAG.getDataLayout().getPointerSize(), dl, MVT::i16);
|
||||
DAG.getConstant(PtrVT.getStoreSize(), dl, MVT::i16);
|
||||
return DAG.getLoad(PtrVT, dl, DAG.getEntryNode(),
|
||||
DAG.getNode(ISD::ADD, dl, PtrVT, FrameAddr, Offset),
|
||||
MachinePointerInfo());
|
||||
|
@ -1308,7 +1310,9 @@ SDValue MSP430TargetLowering::LowerVASTART(SDValue Op,
|
|||
SelectionDAG &DAG) const {
|
||||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
MSP430MachineFunctionInfo *FuncInfo = MF.getInfo<MSP430MachineFunctionInfo>();
|
||||
auto PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
|
||||
SDValue Ptr = Op.getOperand(1);
|
||||
EVT PtrVT = Ptr.getValueType();
|
||||
|
||||
// Frame index of first vararg argument
|
||||
SDValue FrameIndex =
|
||||
|
@ -1316,14 +1320,14 @@ SDValue MSP430TargetLowering::LowerVASTART(SDValue Op,
|
|||
const Value *SV = cast<SrcValueSDNode>(Op.getOperand(2))->getValue();
|
||||
|
||||
// Create a store of the frame index to the location operand
|
||||
return DAG.getStore(Op.getOperand(0), SDLoc(Op), FrameIndex, Op.getOperand(1),
|
||||
return DAG.getStore(Op.getOperand(0), SDLoc(Op), FrameIndex, Ptr,
|
||||
MachinePointerInfo(SV));
|
||||
}
|
||||
|
||||
SDValue MSP430TargetLowering::LowerJumpTable(SDValue Op,
|
||||
SelectionDAG &DAG) const {
|
||||
JumpTableSDNode *JT = cast<JumpTableSDNode>(Op);
|
||||
auto PtrVT = getPointerTy(DAG.getDataLayout());
|
||||
EVT PtrVT = Op.getValueType();
|
||||
SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), PtrVT);
|
||||
return DAG.getNode(MSP430ISD::Wrapper, SDLoc(JT), PtrVT, Result);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue