1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Reverting back 91904.

llvm-svn: 91993
This commit is contained in:
Sanjiv Gupta 2009-12-23 09:46:01 +00:00
parent b4485fd8a9
commit 70e1523215
4 changed files with 10 additions and 60 deletions

View File

@ -36,10 +36,7 @@ class VISIBILITY_HIDDEN PIC16DAGToDAGISel : public SelectionDAGISel {
public: public:
explicit PIC16DAGToDAGISel(PIC16TargetMachine &tm) : explicit PIC16DAGToDAGISel(PIC16TargetMachine &tm) :
SelectionDAGISel(tm), SelectionDAGISel(tm),
TM(tm), PIC16Lowering(*TM.getTargetLowering()) { TM(tm), PIC16Lowering(*TM.getTargetLowering()) {}
// Keep PIC16 specific DAGISel to use during the lowering
PIC16Lowering.ISel = this;
}
// Pass Name // Pass Name
virtual const char *getPassName() const { virtual const char *getPassName() const {

View File

@ -1482,8 +1482,7 @@ bool PIC16TargetLowering::isDirectLoad(const SDValue Op) {
// operand no. of the operand to be converted in 'MemOp'. Remember, PIC16 has // operand no. of the operand to be converted in 'MemOp'. Remember, PIC16 has
// no instruction that can operation on two registers. Most insns take // no instruction that can operation on two registers. Most insns take
// one register and one memory operand (addwf) / Constant (addlw). // one register and one memory operand (addwf) / Constant (addlw).
bool PIC16TargetLowering::NeedToConvertToMemOp(SDValue Op, unsigned &MemOp, bool PIC16TargetLowering::NeedToConvertToMemOp(SDValue Op, unsigned &MemOp) {
SelectionDAG &DAG) {
// If one of the operand is a constant, return false. // If one of the operand is a constant, return false.
if (Op.getOperand(0).getOpcode() == ISD::Constant || if (Op.getOperand(0).getOpcode() == ISD::Constant ||
Op.getOperand(1).getOpcode() == ISD::Constant) Op.getOperand(1).getOpcode() == ISD::Constant)
@ -1492,33 +1491,11 @@ bool PIC16TargetLowering::NeedToConvertToMemOp(SDValue Op, unsigned &MemOp,
// Return false if one of the operands is already a direct // Return false if one of the operands is already a direct
// load and that operand has only one use. // load and that operand has only one use.
if (isDirectLoad(Op.getOperand(0))) { if (isDirectLoad(Op.getOperand(0))) {
if (Op.getOperand(0).hasOneUse()) { if (Op.getOperand(0).hasOneUse())
// Legal and profitable folding check uses the NodeId of DAG nodes. return false;
// This NodeId is assigned by topological order. Therefore first else
// assign topological order then perform legal and profitable check. MemOp = 0;
// Note:- Though this ordering is done before begining with legalization,
// newly added node during legalization process have NodeId=-1 (NewNode)
// therefore before performing any check proper ordering of the node is
// required.
DAG.AssignTopologicalOrder();
// Direct load operands are folded in binary operations. But before folding
// verify if this folding is legal. Fold only if it is legal otherwise
// convert this direct load to a separate memory operation.
if(ISel->IsLegalAndProfitableToFold(Op.getOperand(0).getNode(),
Op.getNode(), Op.getNode()))
return false;
else
MemOp = 0;
}
} }
// For operations that are non-cummutative there is no need to check
// for right operand because folding right operand may result in
// incorrect operation.
if (! SelectionDAG::isCommutativeBinOp(Op.getOpcode()))
return true;
if (isDirectLoad(Op.getOperand(1))) { if (isDirectLoad(Op.getOperand(1))) {
if (Op.getOperand(1).hasOneUse()) if (Op.getOperand(1).hasOneUse())
return false; return false;
@ -1537,7 +1514,7 @@ SDValue PIC16TargetLowering::LowerBinOp(SDValue Op, SelectionDAG &DAG) {
assert (Op.getValueType() == MVT::i8 && "illegal Op to lower"); assert (Op.getValueType() == MVT::i8 && "illegal Op to lower");
unsigned MemOp = 1; unsigned MemOp = 1;
if (NeedToConvertToMemOp(Op, MemOp, DAG)) { if (NeedToConvertToMemOp(Op, MemOp)) {
// Put one value on stack. // Put one value on stack.
SDValue NewVal = ConvertToMemOperand (Op.getOperand(MemOp), DAG, dl); SDValue NewVal = ConvertToMemOperand (Op.getOperand(MemOp), DAG, dl);
@ -1556,7 +1533,7 @@ SDValue PIC16TargetLowering::LowerADD(SDValue Op, SelectionDAG &DAG) {
assert (Op.getValueType() == MVT::i8 && "illegal add to lower"); assert (Op.getValueType() == MVT::i8 && "illegal add to lower");
DebugLoc dl = Op.getDebugLoc(); DebugLoc dl = Op.getDebugLoc();
unsigned MemOp = 1; unsigned MemOp = 1;
if (NeedToConvertToMemOp(Op, MemOp, DAG)) { if (NeedToConvertToMemOp(Op, MemOp)) {
// Put one value on stack. // Put one value on stack.
SDValue NewVal = ConvertToMemOperand (Op.getOperand(MemOp), DAG, dl); SDValue NewVal = ConvertToMemOperand (Op.getOperand(MemOp), DAG, dl);
@ -1587,8 +1564,7 @@ SDValue PIC16TargetLowering::LowerSUB(SDValue Op, SelectionDAG &DAG) {
// Nothing to do if the first operand is already a direct load and it has // Nothing to do if the first operand is already a direct load and it has
// only one use. // only one use.
unsigned MemOp = 0; if (isDirectLoad(Op.getOperand(0)) && Op.getOperand(0).hasOneUse())
if (! NeedToConvertToMemOp(Op, MemOp, DAG))
return Op; return Op;
// Put first operand on stack. // Put first operand on stack.

View File

@ -18,7 +18,6 @@
#include "PIC16.h" #include "PIC16.h"
#include "PIC16Subtarget.h" #include "PIC16Subtarget.h"
#include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/SelectionDAGISel.h"
#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLowering.h"
#include <map> #include <map>
@ -217,9 +216,7 @@ namespace llvm {
// This function checks if we need to put an operand of an operation on // This function checks if we need to put an operand of an operation on
// stack and generate a load or not. // stack and generate a load or not.
// DAG parameter is required to access DAG information during bool NeedToConvertToMemOp(SDValue Op, unsigned &MemOp);
// analysis.
bool NeedToConvertToMemOp(SDValue Op, unsigned &MemOp, SelectionDAG &DAG);
/// Subtarget - Keep a pointer to the PIC16Subtarget around so that we can /// Subtarget - Keep a pointer to the PIC16Subtarget around so that we can
/// make the right decision when generating code for different targets. /// make the right decision when generating code for different targets.
@ -242,11 +239,6 @@ namespace llvm {
// Check if operation has a direct load operand. // Check if operation has a direct load operand.
inline bool isDirectLoad(const SDValue Op); inline bool isDirectLoad(const SDValue Op);
public:
// Keep a pointer to SelectionDAGISel to access its public
// interface (It is required during legalization)
SelectionDAGISel *ISel;
private: private:
// The frameindexes generated for spill/reload are stack based. // The frameindexes generated for spill/reload are stack based.
// This maps maintain zero based indexes for these FIs. // This maps maintain zero based indexes for these FIs.

View File

@ -1,15 +0,0 @@
;RUN: llvm-as < %s | llc -march=pic16
@aa = global i16 55, align 1 ; <i16*> [#uses=1]
@bb = global i16 44, align 1 ; <i16*> [#uses=1]
@PORTD = external global i8 ; <i8*> [#uses=1]
define void @foo() nounwind {
entry:
%tmp = volatile load i16* @aa ; <i16> [#uses=1]
%tmp1 = volatile load i16* @bb ; <i16> [#uses=1]
%sub = sub i16 %tmp, %tmp1 ; <i16> [#uses=1]
%conv = trunc i16 %sub to i8 ; <i8> [#uses=1]
store i8 %conv, i8* @PORTD
ret void
}