mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-23 15:29:51 +00:00
PTX: support for select_cc and fixes for setcc
- expansion of SELECT_CC into SETCC - force SETCC result type to i1 - custom selection for handling i1 using SETCC Patch by Dan Bailey git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130358 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9c86533347
commit
2d525c5532
@ -58,14 +58,28 @@ PTXTargetLowering::PTXTargetLowering(TargetMachine &TM)
|
|||||||
// Expand BR_CC into BRCOND
|
// Expand BR_CC into BRCOND
|
||||||
setOperationAction(ISD::BR_CC, MVT::Other, Expand);
|
setOperationAction(ISD::BR_CC, MVT::Other, Expand);
|
||||||
|
|
||||||
|
// Expand SELECT_CC into SETCC
|
||||||
|
setOperationAction(ISD::SELECT_CC, MVT::Other, Expand);
|
||||||
|
setOperationAction(ISD::SELECT_CC, MVT::f32, Expand);
|
||||||
|
setOperationAction(ISD::SELECT_CC, MVT::f64, Expand);
|
||||||
|
|
||||||
|
// need to lower SETCC of Preds into bitwise logic
|
||||||
|
setOperationAction(ISD::SETCC, MVT::i1, Custom);
|
||||||
|
|
||||||
// Compute derived properties from the register classes
|
// Compute derived properties from the register classes
|
||||||
computeRegisterProperties();
|
computeRegisterProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MVT::SimpleValueType PTXTargetLowering::getSetCCResultType(EVT VT) const {
|
||||||
|
return MVT::i1;
|
||||||
|
}
|
||||||
|
|
||||||
SDValue PTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
|
SDValue PTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
|
||||||
switch (Op.getOpcode()) {
|
switch (Op.getOpcode()) {
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Unimplemented operand");
|
llvm_unreachable("Unimplemented operand");
|
||||||
|
case ISD::SETCC:
|
||||||
|
return LowerSETCC(Op, DAG);
|
||||||
case ISD::GlobalAddress:
|
case ISD::GlobalAddress:
|
||||||
return LowerGlobalAddress(Op, DAG);
|
return LowerGlobalAddress(Op, DAG);
|
||||||
}
|
}
|
||||||
@ -90,6 +104,28 @@ const char *PTXTargetLowering::getTargetNodeName(unsigned Opcode) const {
|
|||||||
// Custom Lower Operation
|
// Custom Lower Operation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
SDValue PTXTargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
|
||||||
|
assert(Op.getValueType() == MVT::i1 && "SetCC type must be 1-bit integer");
|
||||||
|
SDValue Op0 = Op.getOperand(0);
|
||||||
|
SDValue Op1 = Op.getOperand(1);
|
||||||
|
SDValue Op2 = Op.getOperand(2);
|
||||||
|
DebugLoc dl = Op.getDebugLoc();
|
||||||
|
ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(2))->get();
|
||||||
|
|
||||||
|
// Look for X == 0, X == 1, X != 0, or X != 1
|
||||||
|
// We can simplify these to bitwise logic
|
||||||
|
|
||||||
|
if (Op1.getOpcode() == ISD::Constant &&
|
||||||
|
(cast<ConstantSDNode>(Op1)->getZExtValue() == 1 ||
|
||||||
|
cast<ConstantSDNode>(Op1)->isNullValue()) &&
|
||||||
|
(CC == ISD::SETEQ || CC == ISD::SETNE)) {
|
||||||
|
|
||||||
|
return DAG.getNode(ISD::AND, dl, MVT::i1, Op0, Op1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DAG.getNode(ISD::SETCC, dl, MVT::i1, Op0, Op1, Op2);
|
||||||
|
}
|
||||||
|
|
||||||
SDValue PTXTargetLowering::
|
SDValue PTXTargetLowering::
|
||||||
LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const {
|
LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const {
|
||||||
EVT PtrVT = getPointerTy();
|
EVT PtrVT = getPointerTy();
|
||||||
|
@ -42,6 +42,8 @@ class PTXTargetLowering : public TargetLowering {
|
|||||||
|
|
||||||
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
|
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
|
||||||
|
|
||||||
|
virtual SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
|
||||||
|
|
||||||
virtual SDValue
|
virtual SDValue
|
||||||
LowerFormalArguments(SDValue Chain,
|
LowerFormalArguments(SDValue Chain,
|
||||||
CallingConv::ID CallConv,
|
CallingConv::ID CallConv,
|
||||||
@ -60,6 +62,8 @@ class PTXTargetLowering : public TargetLowering {
|
|||||||
DebugLoc dl,
|
DebugLoc dl,
|
||||||
SelectionDAG &DAG) const;
|
SelectionDAG &DAG) const;
|
||||||
|
|
||||||
|
virtual MVT::SimpleValueType getSetCCResultType(EVT VT) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
||||||
}; // class PTXTargetLowering
|
}; // class PTXTargetLowering
|
||||||
|
Loading…
Reference in New Issue
Block a user