mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-05 14:34:55 +00:00
Refactor function that checks that __builtin_returnaddress's argument is constant.
This moves the check up into the parent class so that all targets can use it without having to copy (and keep in sync) the same error message. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7f10681985
commit
4644d79871
@ -2164,6 +2164,10 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool verifyReturnAddressArgumentIsConstant(SDValue Op,
|
||||
SelectionDAG &DAG) const;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Inline Asm Support hooks
|
||||
//
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
@ -2663,3 +2664,14 @@ BuildUDIV(SDNode *N, SelectionDAG &DAG, bool IsAfterLegalization,
|
||||
DAG.getConstant(magics.s-1, getShiftAmountTy(NPQ.getValueType())));
|
||||
}
|
||||
}
|
||||
|
||||
bool TargetLowering::
|
||||
verifyReturnAddressArgumentIsConstant(SDValue Op, SelectionDAG &DAG) const {
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -2132,11 +2132,8 @@ SDValue AArch64TargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) co
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
MFI->setReturnAddressIsTaken(true);
|
||||
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
EVT VT = Op.getValueType();
|
||||
SDLoc dl(Op);
|
||||
|
@ -3753,11 +3753,8 @@ SDValue ARMTargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const{
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
MFI->setReturnAddressIsTaken(true);
|
||||
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
EVT VT = Op.getValueType();
|
||||
SDLoc dl(Op);
|
||||
|
@ -982,11 +982,8 @@ HexagonTargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const {
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
MFI->setReturnAddressIsTaken(true);
|
||||
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
EVT VT = Op.getValueType();
|
||||
SDLoc dl(Op);
|
||||
|
@ -1048,11 +1048,8 @@ SDValue MSP430TargetLowering::LowerRETURNADDR(SDValue Op,
|
||||
MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo();
|
||||
MFI->setReturnAddressIsTaken(true);
|
||||
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
|
||||
SDLoc dl(Op);
|
||||
|
@ -1845,11 +1845,8 @@ lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
|
||||
|
||||
SDValue MipsTargetLowering::lowerRETURNADDR(SDValue Op,
|
||||
SelectionDAG &DAG) const {
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
// check the depth
|
||||
assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) &&
|
||||
|
@ -7796,11 +7796,8 @@ SDValue PPCTargetLowering::LowerRETURNADDR(SDValue Op,
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
MFI->setReturnAddressIsTaken(true);
|
||||
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
SDLoc dl(Op);
|
||||
unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
|
||||
|
@ -2471,11 +2471,8 @@ static SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG,
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
MFI->setReturnAddressIsTaken(true);
|
||||
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (TLI.verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
EVT VT = Op.getValueType();
|
||||
SDLoc dl(Op);
|
||||
|
@ -12173,11 +12173,8 @@ SDValue X86TargetLowering::LowerRETURNADDR(SDValue Op,
|
||||
MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo();
|
||||
MFI->setReturnAddressIsTaken(true);
|
||||
|
||||
if (!isa<ConstantSDNode>(Op.getOperand(0))) {
|
||||
DAG.getContext()->emitError("argument to '__builtin_return_address' must "
|
||||
"be a constant integer");
|
||||
if (verifyReturnAddressArgumentIsConstant(Op, DAG))
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
|
||||
SDLoc dl(Op);
|
||||
|
Loading…
x
Reference in New Issue
Block a user