mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 23:18:51 +00:00
Change ConstantSDNode to store an APInt instead of a uint64_t, and
begin adding some methods to use it this way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46899 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
82ada54da0
commit
6394b099e8
@ -172,10 +172,14 @@ public:
|
|||||||
//
|
//
|
||||||
SDOperand getString(const std::string &Val);
|
SDOperand getString(const std::string &Val);
|
||||||
SDOperand getConstant(uint64_t Val, MVT::ValueType VT, bool isTarget = false);
|
SDOperand getConstant(uint64_t Val, MVT::ValueType VT, bool isTarget = false);
|
||||||
|
SDOperand getConstant(const APInt &Val, MVT::ValueType VT, bool isTarget = false);
|
||||||
SDOperand getIntPtrConstant(uint64_t Val, bool isTarget = false);
|
SDOperand getIntPtrConstant(uint64_t Val, bool isTarget = false);
|
||||||
SDOperand getTargetConstant(uint64_t Val, MVT::ValueType VT) {
|
SDOperand getTargetConstant(uint64_t Val, MVT::ValueType VT) {
|
||||||
return getConstant(Val, VT, true);
|
return getConstant(Val, VT, true);
|
||||||
}
|
}
|
||||||
|
SDOperand getTargetConstant(const APInt &Val, MVT::ValueType VT) {
|
||||||
|
return getConstant(Val, VT, true);
|
||||||
|
}
|
||||||
SDOperand getConstantFP(double Val, MVT::ValueType VT, bool isTarget = false);
|
SDOperand getConstantFP(double Val, MVT::ValueType VT, bool isTarget = false);
|
||||||
SDOperand getConstantFP(const APFloat& Val, MVT::ValueType VT,
|
SDOperand getConstantFP(const APFloat& Val, MVT::ValueType VT,
|
||||||
bool isTarget = false);
|
bool isTarget = false);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "llvm/ADT/GraphTraits.h"
|
#include "llvm/ADT/GraphTraits.h"
|
||||||
#include "llvm/ADT/iterator"
|
#include "llvm/ADT/iterator"
|
||||||
#include "llvm/ADT/APFloat.h"
|
#include "llvm/ADT/APFloat.h"
|
||||||
|
#include "llvm/ADT/APInt.h"
|
||||||
#include "llvm/CodeGen/ValueTypes.h"
|
#include "llvm/CodeGen/ValueTypes.h"
|
||||||
#include "llvm/CodeGen/MemOperand.h"
|
#include "llvm/CodeGen/MemOperand.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
@ -1173,21 +1174,22 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ConstantSDNode : public SDNode {
|
class ConstantSDNode : public SDNode {
|
||||||
uint64_t Value;
|
APInt Value;
|
||||||
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
|
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
|
||||||
protected:
|
protected:
|
||||||
friend class SelectionDAG;
|
friend class SelectionDAG;
|
||||||
ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
|
ConstantSDNode(bool isTarget, const APInt &val, MVT::ValueType VT)
|
||||||
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
|
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
|
||||||
Value(val) {
|
Value(val) {
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
uint64_t getValue() const { return Value; }
|
const APInt &getAPIntValue() const { return Value; }
|
||||||
|
uint64_t getValue() const { return Value.getZExtValue(); }
|
||||||
|
|
||||||
int64_t getSignExtended() const {
|
int64_t getSignExtended() const {
|
||||||
unsigned Bits = MVT::getSizeInBits(getValueType(0));
|
unsigned Bits = MVT::getSizeInBits(getValueType(0));
|
||||||
return ((int64_t)Value << (64-Bits)) >> (64-Bits);
|
return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNullValue() const { return Value == 0; }
|
bool isNullValue() const { return Value == 0; }
|
||||||
|
@ -706,18 +706,25 @@ SDOperand SelectionDAG::getString(const std::string &Val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDOperand SelectionDAG::getConstant(uint64_t Val, MVT::ValueType VT, bool isT) {
|
SDOperand SelectionDAG::getConstant(uint64_t Val, MVT::ValueType VT, bool isT) {
|
||||||
|
MVT::ValueType EltVT =
|
||||||
|
MVT::isVector(VT) ? MVT::getVectorElementType(VT) : VT;
|
||||||
|
|
||||||
|
return getConstant(APInt(MVT::getSizeInBits(EltVT), Val), VT, isT);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDOperand SelectionDAG::getConstant(const APInt &Val, MVT::ValueType VT, bool isT) {
|
||||||
assert(MVT::isInteger(VT) && "Cannot create FP integer constant!");
|
assert(MVT::isInteger(VT) && "Cannot create FP integer constant!");
|
||||||
|
|
||||||
MVT::ValueType EltVT =
|
MVT::ValueType EltVT =
|
||||||
MVT::isVector(VT) ? MVT::getVectorElementType(VT) : VT;
|
MVT::isVector(VT) ? MVT::getVectorElementType(VT) : VT;
|
||||||
|
|
||||||
// Mask out any bits that are not valid for this constant.
|
assert(Val.getBitWidth() == MVT::getSizeInBits(EltVT) &&
|
||||||
Val &= MVT::getIntVTBitMask(EltVT);
|
"APInt size does not match type size!");
|
||||||
|
|
||||||
unsigned Opc = isT ? ISD::TargetConstant : ISD::Constant;
|
unsigned Opc = isT ? ISD::TargetConstant : ISD::Constant;
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0);
|
AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0);
|
||||||
ID.AddInteger(Val);
|
ID.AddAPInt(Val);
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
SDNode *N = NULL;
|
SDNode *N = NULL;
|
||||||
if ((N = CSEMap.FindNodeOrInsertPos(ID, IP)))
|
if ((N = CSEMap.FindNodeOrInsertPos(ID, IP)))
|
||||||
|
Loading…
Reference in New Issue
Block a user