summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-09-12 18:08:03 +0000
committerDan Gohman <gohman@apple.com>2008-09-12 18:08:03 +0000
commit4fbd796a1251a27e6590765a0a34876f436a0af9 (patch)
treef45e414877d264b7244d93b7fdcf28bcbd85fc20 /include
parent913d3dfac43f29921467f33aa743f28ee1bfc5d1 (diff)
downloadllvm-4fbd796a1251a27e6590765a0a34876f436a0af9.tar.gz
llvm-4fbd796a1251a27e6590765a0a34876f436a0af9.tar.bz2
llvm-4fbd796a1251a27e6590765a0a34876f436a0af9.tar.xz
Change ConstantSDNode and ConstantFPSDNode to use ConstantInt* and
ConstantFP* instead of APInt and APFloat directly. This reduces the amount of time to create ConstantSDNode and ConstantFPSDNode nodes when ConstantInt* and ConstantFP* respectively are already available, as is the case in SelectionDAGBuild.cpp. Also, it reduces the amount of time to legalize constants into constant pools, and the amount of time to add ConstantFP operands to MachineInstrs, due to eliminating ConstantInt::get and ConstantFP::get calls. It increases the amount of work needed to create new constants in cases where the client doesn't already have a ConstantInt* or ConstantFP*, such as legalize expanding 64-bit integer constants to 32-bit constants. And it adds a layer of indirection for the accessor methods. But these appear to be outweight by the benefits in most cases. It will also make it easier to make ConstantSDNode and ConstantFPNode more consistent with ConstantInt and ConstantFP. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56162 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h2
-rw-r--r--include/llvm/CodeGen/MachineOperand.h6
-rw-r--r--include/llvm/CodeGen/SelectionDAG.h8
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h32
4 files changed, 28 insertions, 20 deletions
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index 3c0dcfe9ef..c63487d19d 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -52,7 +52,7 @@ public:
return *this;
}
- const MachineInstrBuilder &addFPImm(ConstantFP *Val) const {
+ const MachineInstrBuilder &addFPImm(const ConstantFP *Val) const {
MI->addOperand(MachineOperand::CreateFPImm(Val));
return *this;
}
diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h
index a6830a5c37..28af8ad01f 100644
--- a/include/llvm/CodeGen/MachineOperand.h
+++ b/include/llvm/CodeGen/MachineOperand.h
@@ -86,7 +86,7 @@ private:
/// Contents union - This contains the payload for the various operand types.
union {
MachineBasicBlock *MBB; // For MO_MachineBasicBlock.
- ConstantFP *CFP; // For MO_FPImmediate.
+ const ConstantFP *CFP; // For MO_FPImmediate.
int64_t ImmVal; // For MO_Immediate.
struct { // For MO_Register.
@@ -252,7 +252,7 @@ public:
return Contents.ImmVal;
}
- ConstantFP *getFPImm() const {
+ const ConstantFP *getFPImm() const {
assert(isFPImmediate() && "Wrong MachineOperand accessor");
return Contents.CFP;
}
@@ -340,7 +340,7 @@ public:
return Op;
}
- static MachineOperand CreateFPImm(ConstantFP *CFP) {
+ static MachineOperand CreateFPImm(const ConstantFP *CFP) {
MachineOperand Op(MachineOperand::MO_FPImmediate);
Op.Contents.CFP = CFP;
return Op;
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 9fb0dc44f9..52c67c0c76 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -231,6 +231,7 @@ public:
//
SDValue getConstant(uint64_t Val, MVT VT, bool isTarget = false);
SDValue getConstant(const APInt &Val, MVT VT, bool isTarget = false);
+ SDValue getConstant(const ConstantInt &Val, MVT VT, bool isTarget = false);
SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false);
SDValue getTargetConstant(uint64_t Val, MVT VT) {
return getConstant(Val, VT, true);
@@ -238,14 +239,21 @@ public:
SDValue getTargetConstant(const APInt &Val, MVT VT) {
return getConstant(Val, VT, true);
}
+ SDValue getTargetConstant(const ConstantInt &Val, MVT VT) {
+ return getConstant(Val, VT, true);
+ }
SDValue getConstantFP(double Val, MVT VT, bool isTarget = false);
SDValue getConstantFP(const APFloat& Val, MVT VT, bool isTarget = false);
+ SDValue getConstantFP(const ConstantFP &CF, MVT VT, bool isTarget = false);
SDValue getTargetConstantFP(double Val, MVT VT) {
return getConstantFP(Val, VT, true);
}
SDValue getTargetConstantFP(const APFloat& Val, MVT VT) {
return getConstantFP(Val, VT, true);
}
+ SDValue getTargetConstantFP(const ConstantFP &Val, MVT VT) {
+ return getConstantFP(Val, VT, true);
+ }
SDValue getGlobalAddress(const GlobalValue *GV, MVT VT,
int offset = 0, bool isTargetGA = false);
SDValue getTargetGlobalAddress(const GlobalValue *GV, MVT VT,
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index 33bd4e3d91..7d6a1776aa 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -20,11 +20,10 @@
#define LLVM_CODEGEN_SELECTIONDAGNODES_H
#include "llvm/Value.h"
+#include "llvm/Constants.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator.h"
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/ValueTypes.h"
@@ -1704,28 +1703,27 @@ class AtomicSDNode : public MemSDNode {
};
class ConstantSDNode : public SDNode {
- APInt Value;
+ const ConstantInt *Value;
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- ConstantSDNode(bool isTarget, const APInt &val, MVT VT)
+ ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT)
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
Value(val) {
}
public:
- const APInt &getAPIntValue() const { return Value; }
- uint64_t getZExtValue() const { return Value.getZExtValue(); }
+ const ConstantInt *getConstantIntValue() const { return Value; }
+ const APInt &getAPIntValue() const { return Value->getValue(); }
+ uint64_t getZExtValue() const { return Value->getZExtValue(); }
int64_t getSignExtended() const {
unsigned Bits = getValueType(0).getSizeInBits();
- return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits);
+ return ((int64_t)getZExtValue() << (64-Bits)) >> (64-Bits);
}
- bool isNullValue() const { return Value == 0; }
- bool isAllOnesValue() const {
- return Value == getValueType(0).getIntegerVTBitMask();
- }
+ bool isNullValue() const { return Value->isNullValue(); }
+ bool isAllOnesValue() const { return Value->isAllOnesValue(); }
static bool classof(const ConstantSDNode *) { return true; }
static bool classof(const SDNode *N) {
@@ -1735,17 +1733,18 @@ public:
};
class ConstantFPSDNode : public SDNode {
- APFloat Value;
+ const ConstantFP *Value;
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- ConstantFPSDNode(bool isTarget, const APFloat& val, MVT VT)
+ ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT)
: SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
getSDVTList(VT)), Value(val) {
}
public:
- const APFloat& getValueAPF() const { return Value; }
+ const APFloat& getValueAPF() const { return Value->getValueAPF(); }
+ const ConstantFP *getConstantFPValue() const { return Value; }
/// isExactlyValue - We don't rely on operator== working on double values, as
/// it returns true for things that are clearly not equal, like -0.0 and 0.0.
@@ -1757,10 +1756,11 @@ public:
/// have to duplicate its logic everywhere it's called.
bool isExactlyValue(double V) const {
// convert is not supported on this type
- if (&Value.getSemantics() == &APFloat::PPCDoubleDouble)
+ if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble)
return false;
APFloat Tmp(V);
- Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven);
+ Tmp.convert(Value->getValueAPF().getSemantics(),
+ APFloat::rmNearestTiesToEven);
return isExactlyValue(Tmp);
}
bool isExactlyValue(const APFloat& V) const;