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