Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
Show First 20 Lines • Show All 1,235 Lines • ▼ Show 20 Lines | |||||
/// PromoteIntegerOperand - This method is called when the specified operand of | /// PromoteIntegerOperand - This method is called when the specified operand of | ||||
/// the specified node is found to need promotion. At this point, all of the | /// the specified node is found to need promotion. At this point, all of the | ||||
/// result types of the node are known to be legal, but other operands of the | /// result types of the node are known to be legal, but other operands of the | ||||
/// node may need promotion or expansion as well as the specified one. | /// node may need promotion or expansion as well as the specified one. | ||||
bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) { | bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) { | ||||
LLVM_DEBUG(dbgs() << "Promote integer operand: "; N->dump(&DAG); | LLVM_DEBUG(dbgs() << "Promote integer operand: "; N->dump(&DAG); | ||||
dbgs() << "\n"); | dbgs() << "\n"); | ||||
SDValue Res = SDValue(); | SDValue Res = SDValue(); | ||||
if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) { | if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) { | ||||
john.brawn: Instead of setting this per-opcode in the switch, it would be simpler to do
```
bool IsStrict… | |||||
LLVM_DEBUG(dbgs() << "Node has been custom lowered, done\n"); | LLVM_DEBUG(dbgs() << "Node has been custom lowered, done\n"); | ||||
return false; | return false; | ||||
} | } | ||||
switch (N->getOpcode()) { | switch (N->getOpcode()) { | ||||
default: | default: | ||||
#ifndef NDEBUG | #ifndef NDEBUG | ||||
dbgs() << "PromoteIntegerOperand Op #" << OpNo << ": "; | dbgs() << "PromoteIntegerOperand Op #" << OpNo << ": "; | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) { | ||||
// If the result is null, the sub-method took care of registering results etc. | // If the result is null, the sub-method took care of registering results etc. | ||||
if (!Res.getNode()) return false; | if (!Res.getNode()) return false; | ||||
// If the result is N, the sub-method updated N in place. Tell the legalizer | // If the result is N, the sub-method updated N in place. Tell the legalizer | ||||
// core about this. | // core about this. | ||||
if (Res.getNode() == N) | if (Res.getNode() == N) | ||||
return true; | return true; | ||||
assert(Res.getValueType() == N->getValueType(0) && N->getNumValues() == 1 && | const bool IsStrictFp = N->isStrictFPOpcode(); | ||||
assert(Res.getValueType() == N->getValueType(0) && | |||||
N->getNumValues() == (IsStrictFp ? 2 : 1) && | |||||
"Invalid operand expansion"); | "Invalid operand expansion"); | ||||
LLVM_DEBUG(dbgs() << "Replacing: "; N->dump(&DAG); dbgs() << " with: "; | |||||
Res.dump()); | |||||
ReplaceValueWith(SDValue(N, 0), Res); | ReplaceValueWith(SDValue(N, 0), Res); | ||||
if (IsStrictFp) | |||||
ReplaceValueWith(SDValue(N, 1), SDValue(Res.getNode(), 1)); | |||||
return false; | return false; | ||||
} | } | ||||
/// PromoteSetCCOperands - Promote the operands of a comparison. This code is | /// PromoteSetCCOperands - Promote the operands of a comparison. This code is | ||||
/// shared among BR_CC, SELECT_CC, and SETCC handlers. | /// shared among BR_CC, SELECT_CC, and SETCC handlers. | ||||
void DAGTypeLegalizer::PromoteSetCCOperands(SDValue &NewLHS,SDValue &NewRHS, | void DAGTypeLegalizer::PromoteSetCCOperands(SDValue &NewLHS,SDValue &NewRHS, | ||||
ISD::CondCode CCCode) { | ISD::CondCode CCCode) { | ||||
// We have to insert explicit sign or zero extends. Note that we could | // We have to insert explicit sign or zero extends. Note that we could | ||||
▲ Show 20 Lines • Show All 3,107 Lines • Show Last 20 Lines |
Instead of setting this per-opcode in the switch, it would be simpler to do
and then use IsStrict to decide if there's another result. This is also more similar to how we handle strict opcodes elsewhere in legalization.