aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r--include/llvm/CodeGen/CallingConvLower.h24
-rw-r--r--include/llvm/CodeGen/SelectionDAG.h197
-rw-r--r--include/llvm/CodeGen/SelectionDAGISel.h2
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h79
-rw-r--r--include/llvm/CodeGen/ValueTypes.h731
5 files changed, 516 insertions, 517 deletions
diff --git a/include/llvm/CodeGen/CallingConvLower.h b/include/llvm/CodeGen/CallingConvLower.h
index 584cb19..2fda9e5 100644
--- a/include/llvm/CodeGen/CallingConvLower.h
+++ b/include/llvm/CodeGen/CallingConvLower.h
@@ -49,14 +49,14 @@ private:
LocInfo HTP : 7;
/// ValVT - The type of the value being assigned.
- MVT::ValueType ValVT;
+ MVT ValVT;
/// LocVT - The type of the location being assigned to.
- MVT::ValueType LocVT;
+ MVT LocVT;
public:
- static CCValAssign getReg(unsigned ValNo, MVT::ValueType ValVT,
- unsigned RegNo, MVT::ValueType LocVT,
+ static CCValAssign getReg(unsigned ValNo, MVT ValVT,
+ unsigned RegNo, MVT LocVT,
LocInfo HTP) {
CCValAssign Ret;
Ret.ValNo = ValNo;
@@ -67,8 +67,8 @@ public:
Ret.LocVT = LocVT;
return Ret;
}
- static CCValAssign getMem(unsigned ValNo, MVT::ValueType ValVT,
- unsigned Offset, MVT::ValueType LocVT,
+ static CCValAssign getMem(unsigned ValNo, MVT ValVT,
+ unsigned Offset, MVT LocVT,
LocInfo HTP) {
CCValAssign Ret;
Ret.ValNo = ValNo;
@@ -81,14 +81,14 @@ public:
}
unsigned getValNo() const { return ValNo; }
- MVT::ValueType getValVT() const { return ValVT; }
+ MVT getValVT() const { return ValVT; }
bool isRegLoc() const { return !isMem; }
bool isMemLoc() const { return isMem; }
unsigned getLocReg() const { assert(isRegLoc()); return Loc; }
unsigned getLocMemOffset() const { assert(isMemLoc()); return Loc; }
- MVT::ValueType getLocVT() const { return LocVT; }
+ MVT getLocVT() const { return LocVT; }
LocInfo getLocInfo() const { return HTP; }
};
@@ -96,8 +96,8 @@ public:
/// CCAssignFn - This function assigns a location for Val, updating State to
/// reflect the change.
-typedef bool CCAssignFn(unsigned ValNo, MVT::ValueType ValVT,
- MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
+typedef bool CCAssignFn(unsigned ValNo, MVT ValVT,
+ MVT LocVT, CCValAssign::LocInfo LocInfo,
ISD::ArgFlagsTy ArgFlags, CCState &State);
@@ -217,8 +217,8 @@ public:
// HandleByVal - Allocate a stack slot large enough to pass an argument by
// value. The size and alignment information of the argument is encoded in its
// parameter attribute.
- void HandleByVal(unsigned ValNo, MVT::ValueType ValVT,
- MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
+ void HandleByVal(unsigned ValNo, MVT ValVT,
+ MVT LocVT, CCValAssign::LocInfo LocInfo,
int MinSize, int MinAlign, ISD::ArgFlagsTy ArgFlags);
private:
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 77405e4..e11bd42 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -144,24 +144,22 @@ public:
/// getVTList - Return an SDVTList that represents the list of values
/// specified.
- SDVTList getVTList(MVT::ValueType VT);
- SDVTList getVTList(MVT::ValueType VT1, MVT::ValueType VT2);
- SDVTList getVTList(MVT::ValueType VT1, MVT::ValueType VT2,MVT::ValueType VT3);
- SDVTList getVTList(const MVT::ValueType *VTs, unsigned NumVTs);
+ SDVTList getVTList(MVT VT);
+ SDVTList getVTList(MVT VT1, MVT VT2);
+ SDVTList getVTList(MVT VT1, MVT VT2, MVT VT3);
+ SDVTList getVTList(const MVT *VTs, unsigned NumVTs);
/// getNodeValueTypes - These are obsolete, use getVTList instead.
- const MVT::ValueType *getNodeValueTypes(MVT::ValueType VT) {
+ const MVT *getNodeValueTypes(MVT VT) {
return getVTList(VT).VTs;
}
- const MVT::ValueType *getNodeValueTypes(MVT::ValueType VT1,
- MVT::ValueType VT2) {
+ const MVT *getNodeValueTypes(MVT VT1, MVT VT2) {
return getVTList(VT1, VT2).VTs;
}
- const MVT::ValueType *getNodeValueTypes(MVT::ValueType VT1,MVT::ValueType VT2,
- MVT::ValueType VT3) {
+ const MVT *getNodeValueTypes(MVT VT1, MVT VT2, MVT VT3) {
return getVTList(VT1, VT2, VT3).VTs;
}
- const MVT::ValueType *getNodeValueTypes(std::vector<MVT::ValueType> &vtList) {
+ const MVT *getNodeValueTypes(std::vector<MVT> &vtList) {
return getVTList(&vtList[0], (unsigned)vtList.size()).VTs;
}
@@ -170,57 +168,56 @@ public:
// Node creation methods.
//
SDOperand getString(const std::string &Val);
- SDOperand getConstant(uint64_t Val, MVT::ValueType VT, bool isTarget = false);
- SDOperand getConstant(const APInt &Val, MVT::ValueType VT, bool isTarget = false);
+ SDOperand getConstant(uint64_t Val, MVT VT, bool isTarget = false);
+ SDOperand getConstant(const APInt &Val, MVT VT, 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 VT) {
return getConstant(Val, VT, true);
}
- SDOperand getTargetConstant(const APInt &Val, MVT::ValueType VT) {
+ SDOperand getTargetConstant(const APInt &Val, MVT VT) {
return getConstant(Val, VT, true);
}
- SDOperand getConstantFP(double Val, MVT::ValueType VT, bool isTarget = false);
- SDOperand getConstantFP(const APFloat& Val, MVT::ValueType VT,
- bool isTarget = false);
- SDOperand getTargetConstantFP(double Val, MVT::ValueType VT) {
+ SDOperand getConstantFP(double Val, MVT VT, bool isTarget = false);
+ SDOperand getConstantFP(const APFloat& Val, MVT VT, bool isTarget = false);
+ SDOperand getTargetConstantFP(double Val, MVT VT) {
return getConstantFP(Val, VT, true);
}
- SDOperand getTargetConstantFP(const APFloat& Val, MVT::ValueType VT) {
+ SDOperand getTargetConstantFP(const APFloat& Val, MVT VT) {
return getConstantFP(Val, VT, true);
}
- SDOperand getGlobalAddress(const GlobalValue *GV, MVT::ValueType VT,
+ SDOperand getGlobalAddress(const GlobalValue *GV, MVT VT,
int offset = 0, bool isTargetGA = false);
- SDOperand getTargetGlobalAddress(const GlobalValue *GV, MVT::ValueType VT,
+ SDOperand getTargetGlobalAddress(const GlobalValue *GV, MVT VT,
int offset = 0) {
return getGlobalAddress(GV, VT, offset, true);
}
- SDOperand getFrameIndex(int FI, MVT::ValueType VT, bool isTarget = false);
- SDOperand getTargetFrameIndex(int FI, MVT::ValueType VT) {
+ SDOperand getFrameIndex(int FI, MVT VT, bool isTarget = false);
+ SDOperand getTargetFrameIndex(int FI, MVT VT) {
return getFrameIndex(FI, VT, true);
}
- SDOperand getJumpTable(int JTI, MVT::ValueType VT, bool isTarget = false);
- SDOperand getTargetJumpTable(int JTI, MVT::ValueType VT) {
+ SDOperand getJumpTable(int JTI, MVT VT, bool isTarget = false);
+ SDOperand getTargetJumpTable(int JTI, MVT VT) {
return getJumpTable(JTI, VT, true);
}
- SDOperand getConstantPool(Constant *C, MVT::ValueType VT,
+ SDOperand getConstantPool(Constant *C, MVT VT,
unsigned Align = 0, int Offs = 0, bool isT=false);
- SDOperand getTargetConstantPool(Constant *C, MVT::ValueType VT,
+ SDOperand getTargetConstantPool(Constant *C, MVT VT,
unsigned Align = 0, int Offset = 0) {
return getConstantPool(C, VT, Align, Offset, true);
}
- SDOperand getConstantPool(MachineConstantPoolValue *C, MVT::ValueType VT,
+ SDOperand getConstantPool(MachineConstantPoolValue *C, MVT VT,
unsigned Align = 0, int Offs = 0, bool isT=false);
SDOperand getTargetConstantPool(MachineConstantPoolValue *C,
- MVT::ValueType VT, unsigned Align = 0,
+ MVT VT, unsigned Align = 0,
int Offset = 0) {
return getConstantPool(C, VT, Align, Offset, true);
}
SDOperand getBasicBlock(MachineBasicBlock *MBB);
- SDOperand getExternalSymbol(const char *Sym, MVT::ValueType VT);
- SDOperand getTargetExternalSymbol(const char *Sym, MVT::ValueType VT);
+ SDOperand getExternalSymbol(const char *Sym, MVT VT);
+ SDOperand getTargetExternalSymbol(const char *Sym, MVT VT);
SDOperand getArgFlags(ISD::ArgFlagsTy Flags);
- SDOperand getValueType(MVT::ValueType);
- SDOperand getRegister(unsigned Reg, MVT::ValueType VT);
+ SDOperand getValueType(MVT);
+ SDOperand getRegister(unsigned Reg, MVT VT);
SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N) {
return getNode(ISD::CopyToReg, MVT::Other, Chain,
@@ -232,7 +229,7 @@ public:
// null) and that there should be a flag result.
SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N,
SDOperand Flag) {
- const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
+ const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
SDOperand Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag };
return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
}
@@ -240,13 +237,13 @@ public:
// Similar to last getCopyToReg() except parameter Reg is a SDOperand
SDOperand getCopyToReg(SDOperand Chain, SDOperand Reg, SDOperand N,
SDOperand Flag) {
- const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
+ const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
SDOperand Ops[] = { Chain, Reg, N, Flag };
return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
}
- SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT, MVT::Other);
+ SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT VT) {
+ const MVT *VTs = getNodeValueTypes(VT, MVT::Other);
SDOperand Ops[] = { Chain, getRegister(Reg, VT) };
return getNode(ISD::CopyFromReg, VTs, 2, Ops, 2);
}
@@ -254,9 +251,9 @@ public:
// This version of the getCopyFromReg method takes an extra operand, which
// indicates that there is potentially an incoming flag value (if Flag is not
// null) and that there should be a flag result.
- SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT,
+ SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT VT,
SDOperand Flag) {
- const MVT::ValueType *VTs = getNodeValueTypes(VT, MVT::Other, MVT::Flag);
+ const MVT *VTs = getNodeValueTypes(VT, MVT::Other, MVT::Flag);
SDOperand Ops[] = { Chain, getRegister(Reg, VT), Flag };
return getNode(ISD::CopyFromReg, VTs, 3, Ops, Flag.Val ? 3 : 2);
}
@@ -265,12 +262,12 @@ public:
/// getZeroExtendInReg - Return the expression required to zero extend the Op
/// value assuming it was the smaller SrcTy value.
- SDOperand getZeroExtendInReg(SDOperand Op, MVT::ValueType SrcTy);
+ SDOperand getZeroExtendInReg(SDOperand Op, MVT SrcTy);
/// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have
/// a flag result (to ensure it's not CSE'd).
SDOperand getCALLSEQ_START(SDOperand Chain, SDOperand Op) {
- const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
+ const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
SDOperand Ops[] = { Chain, Op };
return getNode(ISD::CALLSEQ_START, VTs, 2, Ops, 2);
}
@@ -291,27 +288,24 @@ public:
/// getNode - Gets or creates the specified node.
///
- SDOperand getNode(unsigned Opcode, MVT::ValueType VT);
- SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N);
- SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand N1, SDOperand N2);
- SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand getNode(unsigned Opcode, MVT VT);
+ SDOperand getNode(unsigned Opcode, MVT VT, SDOperand N);
+ SDOperand getNode(unsigned Opcode, MVT VT, SDOperand N1, SDOperand N2);
+ SDOperand getNode(unsigned Opcode, MVT VT,
SDOperand N1, SDOperand N2, SDOperand N3);
- SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand getNode(unsigned Opcode, MVT VT,
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4);
- SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand getNode(unsigned Opcode, MVT VT,
SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
SDOperand N5);
- SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand getNode(unsigned Opcode, MVT VT, SDOperandPtr Ops, unsigned NumOps);
+ SDOperand getNode(unsigned Opcode, std::vector<MVT> &ResultTys,
SDOperandPtr Ops, unsigned NumOps);
- SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
- SDOperandPtr Ops, unsigned NumOps);
- SDOperand getNode(unsigned Opcode, const MVT::ValueType *VTs, unsigned NumVTs,
+ SDOperand getNode(unsigned Opcode, const MVT *VTs, unsigned NumVTs,
SDOperandPtr Ops, unsigned NumOps);
SDOperand getNode(unsigned Opcode, SDVTList VTs);
SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand N);
- SDOperand getNode(unsigned Opcode, SDVTList VTs,
- SDOperand N1, SDOperand N2);
+ SDOperand getNode(unsigned Opcode, SDVTList VTs, SDOperand N1, SDOperand N2);
SDOperand getNode(unsigned Opcode, SDVTList VTs,
SDOperand N1, SDOperand N2, SDOperand N3);
SDOperand getNode(unsigned Opcode, SDVTList VTs,
@@ -340,7 +334,7 @@ public:
/// getSetCC - Helper function to make it easier to build SetCC's if you just
/// have an ISD::CondCode instead of an SDOperand.
///
- SDOperand getSetCC(MVT::ValueType VT, SDOperand LHS, SDOperand RHS,
+ SDOperand getSetCC(MVT VT, SDOperand LHS, SDOperand RHS,
ISD::CondCode Cond) {
return getNode(ISD::SETCC, VT, LHS, RHS, getCondCode(Cond));
}
@@ -348,7 +342,7 @@ public:
/// getVSetCC - Helper function to make it easier to build VSetCC's nodes
/// if you just have an ISD::CondCode instead of an SDOperand.
///
- SDOperand getVSetCC(MVT::ValueType VT, SDOperand LHS, SDOperand RHS,
+ SDOperand getVSetCC(MVT VT, SDOperand LHS, SDOperand RHS,
ISD::CondCode Cond) {
return getNode(ISD::VSETCC, VT, LHS, RHS, getCondCode(Cond));
}
@@ -364,35 +358,35 @@ public:
/// getVAArg - VAArg produces a result and token chain, and takes a pointer
/// and a source value as input.
- SDOperand getVAArg(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
+ SDOperand getVAArg(MVT VT, SDOperand Chain, SDOperand Ptr,
SDOperand SV);
/// getAtomic - Gets a node for an atomic op, produces result and chain, takes
// 3 operands
SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr,
- SDOperand Cmp, SDOperand Swp, MVT::ValueType VT);
+ SDOperand Cmp, SDOperand Swp, MVT VT);
/// getAtomic - Gets a node for an atomic op, produces result and chain, takes
// 2 operands
SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr,
- SDOperand Val, MVT::ValueType VT);
+ SDOperand Val, MVT VT);
/// getLoad - Loads are not normal binary operators: their result type is not
/// determined by their operands, and they produce a value AND a token chain.
///
- SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
+ SDOperand getLoad(MVT VT, SDOperand Chain, SDOperand Ptr,
const Value *SV, int SVOffset, bool isVolatile=false,
unsigned Alignment=0);
- SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
+ SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT VT,
SDOperand Chain, SDOperand Ptr, const Value *SV,
- int SVOffset, MVT::ValueType EVT, bool isVolatile=false,
+ int SVOffset, MVT EVT, bool isVolatile=false,
unsigned Alignment=0);
SDOperand getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
SDOperand Offset, ISD::MemIndexedMode AM);
SDOperand getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
- MVT::ValueType VT, SDOperand Chain,
+ MVT VT, SDOperand Chain,
SDOperand Ptr, SDOperand Offset,
- const Value *SV, int SVOffset, MVT::ValueType EVT,
+ const Value *SV, int SVOffset, MVT EVT,
bool isVolatile=false, unsigned Alignment=0);
/// getStore - Helper function to build ISD::STORE nodes.
@@ -401,7 +395,7 @@ public:
const Value *SV, int SVOffset, bool isVolatile=false,
unsigned Alignment=0);
SDOperand getTruncStore(SDOperand Chain, SDOperand Val, SDOperand Ptr,
- const Value *SV, int SVOffset, MVT::ValueType TVT,
+ const Value *SV, int SVOffset, MVT TVT,
bool isVolatile=false, unsigned Alignment=0);
SDOperand getIndexedStore(SDOperand OrigStoe, SDOperand Base,
SDOperand Offset, ISD::MemIndexedMode AM);
@@ -434,20 +428,18 @@ public:
/// operands. Note that target opcodes are stored as
/// ISD::BUILTIN_OP_END+TargetOpcode in the node opcode field. The 0th value
/// of the resultant node is returned.
- SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT);
- SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
- SDOperand Op1);
- SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
+ SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT);
+ SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, SDOperand Op1);
+ SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
SDOperand Op1, SDOperand Op2);
- SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
+ SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3);
- SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
+ SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
SDOperandPtr Ops, unsigned NumOps);
- SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
- SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
- SDOperand Op3);
+ SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
+ MVT VT2, SDOperand Op1, SDOperand Op2);
+ SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1,
+ MVT VT2, SDOperand Op1, SDOperand Op2, SDOperand Op3);
/// getTargetNode - These are used for target selectors to create a new node
@@ -456,41 +448,30 @@ public:
/// Note that getTargetNode returns the resultant node. If there is already a
/// node of the specified opcode and operands, it returns that node instead of
/// the current one.
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDNode *getTargetNode(unsigned Opcode, MVT VT);
+ SDNode *getTargetNode(unsigned Opcode, MVT VT, SDOperand Op1);
+ SDNode *getTargetNode(unsigned Opcode, MVT VT, SDOperand Op1, SDOperand Op2);
+ SDNode *getTargetNode(unsigned Opcode, MVT VT,
SDOperand Op1, SDOperand Op2, SDOperand Op3);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDNode *getTargetNode(unsigned Opcode, MVT VT,
SDOperandPtr Ops, unsigned NumOps);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
- SDOperand Op3);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2,
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2);
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, SDOperand Op1);
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1,
+ MVT VT2, SDOperand Op1, SDOperand Op2);
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1,
+ MVT VT2, SDOperand Op1, SDOperand Op2, SDOperand Op3);
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2,
SDOperandPtr Ops, unsigned NumOps);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3,
SDOperand Op1, SDOperand Op2);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3,
SDOperand Op1, SDOperand Op2, SDOperand Op3);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3,
SDOperandPtr Ops, unsigned NumOps);
- SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
- MVT::ValueType VT4,
+ SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, MVT VT4,
SDOperandPtr Ops, unsigned NumOps);
- SDNode *getTargetNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
+ SDNode *getTargetNode(unsigned Opcode, std::vector<MVT> &ResultTys,
SDOperandPtr Ops, unsigned NumOps);
/// getNodeIfExists - Get the specified node if it's already available, or
@@ -570,10 +551,10 @@ public:
/// CreateStackTemporary - Create a stack temporary, suitable for holding the
/// specified value type.
- SDOperand CreateStackTemporary(MVT::ValueType VT);
+ SDOperand CreateStackTemporary(MVT VT);
/// FoldSetCC - Constant fold a setcc to true or false.
- SDOperand FoldSetCC(MVT::ValueType VT, SDOperand N1,
+ SDOperand FoldSetCC(MVT VT, SDOperand N1,
SDOperand N2, ISD::CondCode Cond);
/// SignBitIsZero - Return true if the sign bit of Op is known to be zero. We
@@ -623,13 +604,13 @@ private:
void DeleteNodeNotInCSEMaps(SDNode *N);
// List of non-single value types.
- std::list<std::vector<MVT::ValueType> > VTList;
+ std::list<std::vector<MVT> > VTList;
// Maps to auto-CSE operations.
std::vector<CondCodeSDNode*> CondCodeNodes;
std::vector<SDNode*> ValueTypeNodes;
- std::map<MVT::ValueType, SDNode*> ExtendedValueTypeNodes;
+ std::map<MVT, SDNode*> ExtendedValueTypeNodes;
std::map<std::string, SDNode*> ExternalSymbols;
std::map<std::string, SDNode*> TargetExternalSymbols;
std::map<std::string, StringSDNode*> StringNodes;
diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h
index f981687..fc6b9fb 100644
--- a/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/include/llvm/CodeGen/SelectionDAGISel.h
@@ -55,7 +55,7 @@ public:
virtual bool runOnFunction(Function &Fn);
- unsigned MakeReg(MVT::ValueType VT);
+ unsigned MakeReg(MVT VT);
virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {}
virtual void InstructionSelectBasicBlock(SelectionDAG &SD) = 0;
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index 081b0e1..c2e4f1f 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -48,7 +48,7 @@ template<typename NodeTy> class ilist_iterator;
/// SelectionDAG::getVTList(...).
///
struct SDVTList {
- const MVT::ValueType *VTs;
+ const MVT *VTs;
unsigned short NumVTs;
};
@@ -834,12 +834,12 @@ public:
/// getValueType - Return the ValueType of the referenced return value.
///
- inline MVT::ValueType getValueType() const;
+ inline MVT getValueType() const;
- /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType()).
+ /// getValueSizeInBits - Returns the size of the value in bits.
///
unsigned getValueSizeInBits() const {
- return MVT::getSizeInBits(getValueType());
+ return getValueType().getSizeInBits();
}
// Forwarding methods - These forward to the corresponding methods in SDNode.
@@ -1045,7 +1045,7 @@ private:
/// ValueList - The types of the values this node defines. SDNode's may
/// define multiple values simultaneously.
- const MVT::ValueType *ValueList;
+ const MVT *ValueList;
/// NumOperands/NumValues - The number of entries in the Operand/Value list.
unsigned short NumOperands, NumValues;
@@ -1216,7 +1216,7 @@ public:
/// getValueType - Return the type of a specified result.
///
- MVT::ValueType getValueType(unsigned ResNo) const {
+ MVT getValueType(unsigned ResNo) const {
assert(ResNo < NumValues && "Illegal result number!");
return ValueList[ResNo];
}
@@ -1224,10 +1224,10 @@ public:
/// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
///
unsigned getValueSizeInBits(unsigned ResNo) const {
- return MVT::getSizeInBits(getValueType(ResNo));
+ return getValueType(ResNo).getSizeInBits();
}
- typedef const MVT::ValueType* value_iterator;
+ typedef const MVT* value_iterator;
value_iterator value_begin() const { return ValueList; }
value_iterator value_end() const { return ValueList+NumValues; }
@@ -1249,8 +1249,8 @@ protected:
/// getValueTypeList - Return a pointer to the specified value type.
///
- static const MVT::ValueType *getValueTypeList(MVT::ValueType VT);
- static SDVTList getSDVTList(MVT::ValueType VT) {
+ static const MVT *getValueTypeList(MVT VT);
+ static SDVTList getSDVTList(MVT VT) {
SDVTList Ret = { getValueTypeList(VT), 1 };
return Ret;
}
@@ -1344,7 +1344,7 @@ protected:
inline unsigned SDOperand::getOpcode() const {
return Val->getOpcode();
}
-inline MVT::ValueType SDOperand::getValueType() const {
+inline MVT SDOperand::getValueType() const {
return Val->getValueType(ResNo);
}
inline unsigned SDOperand::getNumOperands() const {
@@ -1439,10 +1439,10 @@ public:
class AtomicSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
SDUse Ops[4];
- MVT::ValueType OrigVT;
+ MVT OrigVT;
public:
AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr,
- SDOperand Cmp, SDOperand Swp, MVT::ValueType VT)
+ SDOperand Cmp, SDOperand Swp, MVT VT)
: SDNode(Opc, VTL) {
Ops[0] = Chain;
Ops[1] = Ptr;
@@ -1452,7 +1452,7 @@ public:
OrigVT=VT;
}
AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr,
- SDOperand Val, MVT::ValueType VT)
+ SDOperand Val, MVT VT)
: SDNode(Opc, VTL) {
Ops[0] = Chain;
Ops[1] = Ptr;
@@ -1460,7 +1460,7 @@ public:
InitOperands(Ops, 3);
OrigVT=VT;
}
- MVT::ValueType getVT() const { return OrigVT; }
+ MVT getVT() const { return OrigVT; }
bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_LCS; }
};
@@ -1485,7 +1485,7 @@ class ConstantSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- ConstantSDNode(bool isTarget, const APInt &val, MVT::ValueType VT)
+ ConstantSDNode(bool isTarget, const APInt &val, MVT VT)
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
Value(val) {
}
@@ -1495,13 +1495,13 @@ public:
uint64_t getValue() const { return Value.getZExtValue(); }
int64_t getSignExtended() const {
- unsigned Bits = MVT::getSizeInBits(getValueType(0));
+ unsigned Bits = getValueType(0).getSizeInBits();
return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits);
}
bool isNullValue() const { return Value == 0; }
bool isAllOnesValue() const {
- return Value == MVT::getIntVTBitMask(getValueType(0));
+ return Value == getValueType(0).getIntegerVTBitMask();
}
static bool classof(const ConstantSDNode *) { return true; }
@@ -1516,7 +1516,7 @@ class ConstantFPSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- ConstantFPSDNode(bool isTarget, const APFloat& val, MVT::ValueType VT)
+ ConstantFPSDNode(bool isTarget, const APFloat& val, MVT VT)
: SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
getSDVTList(VT)), Value(val) {
}
@@ -1542,7 +1542,7 @@ public:
}
bool isExactlyValue(const APFloat& V) const;
- bool isValueValidForType(MVT::ValueType VT, const APFloat& Val);
+ bool isValueValidForType(MVT VT, const APFloat& Val);
static bool classof(const ConstantFPSDNode *) { return true; }
static bool classof(const SDNode *N) {
@@ -1557,8 +1557,7 @@ class GlobalAddressSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
- int o = 0);
+ GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, int o = 0);
public:
GlobalValue *getGlobal() const { return TheGlobal; }
@@ -1578,7 +1577,7 @@ class FrameIndexSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
+ FrameIndexSDNode(int fi, MVT VT, bool isTarg)
: SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
FI(fi) {
}
@@ -1598,7 +1597,7 @@ class JumpTableSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg)
+ JumpTableSDNode(int jti, MVT VT, bool isTarg)
: SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
JTI(jti) {
}
@@ -1623,22 +1622,20 @@ class ConstantPoolSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
- int o=0)
+ ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
getSDVTList(VT)), Offset(o), Alignment(0) {
assert((int)Offset >= 0 && "Offset is too large");
Val.ConstVal = c;
}
- ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
- unsigned Align)
+ ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
getSDVTList(VT)), Offset(o), Alignment(Align) {
assert((int)Offset >= 0 && "Offset is too large");
Val.ConstVal = c;
}
ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
- MVT::ValueType VT, int o=0)
+ MVT VT, int o=0)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
getSDVTList(VT)), Offset(o), Alignment(0) {
assert((int)Offset >= 0 && "Offset is too large");
@@ -1646,7 +1643,7 @@ protected:
Offset |= 1 << (sizeof(unsigned)*8-1);
}
ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
- MVT::ValueType VT, int o, unsigned Align)
+ MVT VT, int o, unsigned Align)
: SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
getSDVTList(VT)), Offset(o), Alignment(Align) {
assert((int)Offset >= 0 && "Offset is too large");
@@ -1760,7 +1757,7 @@ class RegisterSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- RegisterSDNode(unsigned reg, MVT::ValueType VT)
+ RegisterSDNode(unsigned reg, MVT VT)
: SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
}
public:
@@ -1778,7 +1775,7 @@ class ExternalSymbolSDNode : public SDNode {
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
+ ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
: SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
getSDVTList(VT)), Symbol(Sym) {
}
@@ -1914,19 +1911,19 @@ public:
}
};
-/// VTSDNode - This class is used to represent MVT::ValueType's, which are used
+/// VTSDNode - This class is used to represent MVT's, which are used
/// to parameterize some operations.
class VTSDNode : public SDNode {
- MVT::ValueType ValueType;
+ MVT ValueType;
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
protected:
friend class SelectionDAG;
- explicit VTSDNode(MVT::ValueType VT)
+ explicit VTSDNode(MVT VT)
: SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
}
public:
- MVT::ValueType getVT() const { return ValueType; }
+ MVT getVT() const { return ValueType; }
static bool classof(const VTSDNode *) { return true; }
static bool classof(const SDNode *N) {
@@ -1942,7 +1939,7 @@ private:
ISD::MemIndexedMode AddrMode;
// MemoryVT - VT of in-memory value.
- MVT::ValueType MemoryVT;
+ MVT MemoryVT;
//! SrcValue - Memory location for alias analysis.
const Value *SrcValue;
@@ -1965,7 +1962,7 @@ protected:
SDUse Ops[4];
public:
LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned numOperands,
- SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT,
+ SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
const Value *SV, int SVO, unsigned Align, bool Vol)
: SDNode(NodeTy, VTs),
AddrMode(AM), MemoryVT(VT),
@@ -1989,7 +1986,7 @@ public:
const Value *getSrcValue() const { return SrcValue; }
int getSrcValueOffset() const { return SVOffset; }
unsigned getAlignment() const { return Alignment; }
- MVT::ValueType getMemoryVT() const { return MemoryVT; }
+ MVT getMemoryVT() const { return MemoryVT; }
bool isVolatile() const { return IsVolatile; }
ISD::MemIndexedMode getAddressingMode() const { return AddrMode; }
@@ -2022,7 +2019,7 @@ class LoadSDNode : public LSBaseSDNode {
protected:
friend class SelectionDAG;
LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs,
- ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
+ ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
: LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
VTs, AM, LVT, SV, O, Align, Vol),
@@ -2049,7 +2046,7 @@ class StoreSDNode : public LSBaseSDNode {
protected:
friend class SelectionDAG;
StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs,
- ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT,
+ ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
: LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
VTs, AM, SVT, SV, O, Align, Vol),
diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h
index 6b20b7d..1469f81 100644
--- a/include/llvm/CodeGen/ValueTypes.h
+++ b/include/llvm/CodeGen/ValueTypes.h
@@ -24,368 +24,389 @@
namespace llvm {
class Type;
-/// MVT namespace - This namespace defines the SimpleValueType enum, which
-/// contains the various low-level value types, and the ValueType typedef.
-///
-namespace MVT { // MVT = Machine Value Types
- enum SimpleValueType {
- // If you change this numbering, you must change the values in ValueTypes.td
- // well!
- Other = 0, // This is a non-standard value
- i1 = 1, // This is a 1 bit integer value
- i8 = 2, // This is an 8 bit integer value
- i16 = 3, // This is a 16 bit integer value
- i32 = 4, // This is a 32 bit integer value
- i64 = 5, // This is a 64 bit integer value
- i128 = 6, // This is a 128 bit integer value
-
- FIRST_INTEGER_VALUETYPE = i1,
- LAST_INTEGER_VALUETYPE = i128,
-
- f32 = 7, // This is a 32 bit floating point value
- f64 = 8, // This is a 64 bit floating point value
- f80 = 9, // This is a 80 bit floating point value
- f128 = 10, // This is a 128 bit floating point value
- ppcf128 = 11, // This is a PPC 128-bit floating point value
- Flag = 12, // This is a condition code or machine flag.
-
- isVoid = 13, // This has no value
-
- v8i8 = 14, // 8 x i8
- v4i16 = 15, // 4 x i16
- v2i32 = 16, // 2 x i32
- v1i64 = 17, // 1 x i64
- v16i8 = 18, // 16 x i8
- v8i16 = 19, // 8 x i16
- v3i32 = 20, // 3 x i32
- v4i32 = 21, // 4 x i32
- v2i64 = 22, // 2 x i64
-
- v2f32 = 23, // 2 x f32
- v3f32 = 24, // 3 x f32
- v4f32 = 25, // 4 x f32
- v2f64 = 26, // 2 x f64
-
- FIRST_VECTOR_VALUETYPE = v8i8,
- LAST_VECTOR_VALUETYPE = v2f64,
-
- LAST_VALUETYPE = 27, // This always remains at the end of the list.
-
- // fAny - Any floating-point or vector floating-point value. This is used
- // for intrinsics that have overloadings based on floating-point types.
- // This is only for tblgen's consumption!
- fAny = 253,
-
- // iAny - An integer or vector integer value of any bit width. This is
- // used for intrinsics that have overloadings based on integer bit widths.
- // This is only for tblgen's consumption!
- iAny = 254,
-
- // iPTR - An int value the size of the pointer of the current
- // target. This should only be used internal to tblgen!
- iPTR = 255
- };
+ struct MVT { // MVT = Machine Value Type
+
+ enum SimpleValueType {
+ // If you change this numbering, you must change the values in
+ // ValueTypes.td well!
+ Other = 0, // This is a non-standard value
+ i1 = 1, // This is a 1 bit integer value
+ i8 = 2, // This is an 8 bit integer value
+ i16 = 3, // This is a 16 bit integer value
+ i32 = 4, // This is a 32 bit integer value
+ i64 = 5, // This is a 64 bit integer value
+ i128 = 6, // This is a 128 bit integer value
+
+ FIRST_INTEGER_VALUETYPE = i1,
+ LAST_INTEGER_VALUETYPE = i128,
+
+ f32 = 7, // This is a 32 bit floating point value
+ f64 = 8, // This is a 64 bit floating point value
+ f80 = 9, // This is a 80 bit floating point value
+ f128 = 10, // This is a 128 bit floating point value
+ ppcf128 = 11, // This is a PPC 128-bit floating point value
+ Flag = 12, // This is a condition code or machine flag.
+
+ isVoid = 13, // This has no value
+
+ v8i8 = 14, // 8 x i8
+ v4i16 = 15, // 4 x i16
+ v2i32 = 16, // 2 x i32
+ v1i64 = 17, // 1 x i64
+ v16i8 = 18, // 16 x i8
+ v8i16 = 19, // 8 x i16
+ v3i32 = 20, // 3 x i32
+ v4i32 = 21, // 4 x i32
+ v2i64 = 22, // 2 x i64
+
+ v2f32 = 23, // 2 x f32
+ v3f32 = 24, // 3 x f32
+ v4f32 = 25, // 4 x f32
+ v2f64 = 26, // 2 x f64
+
+ FIRST_VECTOR_VALUETYPE = v8i8,
+ LAST_VECTOR_VALUETYPE = v2f64,
+
+ LAST_VALUETYPE = 27, // This always remains at the end of the list.
+
+ // fAny - Any floating-point or vector floating-point value. This is used
+ // for intrinsics that have overloadings based on floating-point types.
+ // This is only for tblgen's consumption!
+ fAny = 253,
+
+ // iAny - An integer or vector integer value of any bit width. This is
+ // used for intrinsics that have overloadings based on integer bit widths.
+ // This is only for tblgen's consumption!
+ iAny = 254,
+
+ // iPTR - An int value the size of the pointer of the current
+ // target. This should only be used internal to tblgen!
+ iPTR = 255
+ };
+
+ /// MVT - This type holds low-level value types. Valid values include any of
+ /// the values in the SimpleValueType enum, or any value returned from one
+ /// of the MVT methods. Any value type equal to one of the SimpleValueType
+ /// enum values is a "simple" value type. All others are "extended".
+ ///
+ /// Note that simple doesn't necessary mean legal for the target machine.
+ /// All legal value types must be simple, but often there are some simple
+ /// value types that are not legal.
+ ///
+ /// @internal
+ /// Extended types are either vector types or arbitrary precision integers.
+ /// Arbitrary precision integers have iAny in the first SimpleTypeBits bits,
+ /// and the bit-width in the next PrecisionBits bits, offset by minus one.
+ /// Vector types are encoded by having the first SimpleTypeBits+PrecisionBits
+ /// bits encode the vector element type (which must be a scalar type, possibly
+ /// an arbitrary precision integer) and the remaining VectorBits upper bits
+ /// encode the vector length, offset by one.
+ ///
+ /// 31--------------16-----------8-------------0
+ /// | Vector length | Precision | Simple type |
+ /// | | Vector element |
+ ///
+
+ static const int SimpleTypeBits = 8;
+ static const int PrecisionBits = 8;
+ static const int VectorBits = 32 - SimpleTypeBits - PrecisionBits;
+
+ static const uint32_t SimpleTypeMask =
+ (~uint32_t(0) << (32 - SimpleTypeBits)) >> (32 - SimpleTypeBits);
+
+ static const uint32_t PrecisionMask =
+ ((~uint32_t(0) << VectorBits) >> (32 - PrecisionBits)) << SimpleTypeBits;
+
+ static const uint32_t VectorMask =
+ (~uint32_t(0) >> (32 - VectorBits)) << (32 - VectorBits);
+
+ static const uint32_t ElementMask =
+ (~uint32_t(0) << VectorBits) >> VectorBits;
+
+ uint32_t V;
+
+ MVT() {}
+ MVT(SimpleValueType S) { V = S; }
+ inline bool operator== (const MVT VT) const { return V == VT.V; }
+ inline bool operator!= (const MVT VT) const { return V != VT.V; }
+
+ /// FIXME: The following comparison methods are bogus - they are only here
+ /// to ease the transition to a struct type.
+ inline bool operator< (const MVT VT) const { return V < VT.V; }
+ inline bool operator<= (const MVT VT) const { return V <= VT.V; }
+ inline bool operator> (const MVT VT) const { return V > VT.V; }
+ inline bool operator>= (const MVT VT) const { return V >= VT.V; }
+
+ /// getIntegerVT - Returns the MVT that represents an integer with the given
+ /// number of bits.
+ static inline MVT getIntegerVT(unsigned BitWidth) {
+ switch (BitWidth) {
+ default:
+ break;
+ case 1:
+ return i1;
+ case 8:
+ return i8;
+ case 16:
+ return i16;
+ case 32:
+ return i32;
+ case 64:
+ return i64;
+ case 128:
+ return i128;
+ }
+ MVT VT;
+ VT.V = iAny | (((BitWidth - 1) << SimpleTypeBits) & PrecisionMask);
+ assert(VT.getSizeInBits() == BitWidth && "Bad bit width!");
+ return VT;
+ }
+
+ /// getVectorVT - Returns the MVT that represents a vector NumElements in
+ /// length, where each element is of type VT.
+ static inline MVT getVectorVT(MVT VT, unsigned NumElements) {
+ switch (VT.V) {
+ default:
+ break;
+ case i8:
+ if (NumElements == 8) return v8i8;
+ if (NumElements == 16) return v16i8;
+ break;
+ case i16:
+ if (NumElements == 4) return v4i16;
+ if (NumElements == 8) return v8i16;
+ break;
+ case i32:
+ if (NumElements == 2) return v2i32;
+ if (NumElements == 3) return v3i32;
+ if (NumElements == 4) return v4i32;
+ break;
+ case i64:
+ if (NumElements == 1) return v1i64;
+ if (NumElements == 2) return v2i64;
+ break;
+ case f32:
+ if (NumElements == 2) return v2f32;
+ if (NumElements == 3) return v3f32;
+ if (NumElements == 4) return v4f32;
+ break;
+ case f64:
+ if (NumElements == 2) return v2f64;
+ break;
+ }
+ // Set the length with the top bit forced to zero (needed by the verifier).
+ MVT Result;
+ Result.V = VT.V | (((NumElements + 1) << (33 - VectorBits)) >> 1);
+ assert(Result.getVectorElementType() == VT &&
+ "Bad vector element type!");
+ assert(Result.getVectorNumElements() == NumElements &&
+ "Bad vector length!");
+ return Result;
+ }
+
+ /// getIntVectorWithNumElements - Return any integer vector type that has
+ /// the specified number of elements.
+ static inline MVT getIntVectorWithNumElements(unsigned NumElts) {
+ switch (NumElts) {
+ default: return getVectorVT(i8, NumElts);
+ case 1: return v1i64;
+ case 2: return v2i32;
+ case 3: return v3i32;
+ case 4: return v4i16;
+ case 8: return v8i8;
+ case 16: return v16i8;
+ }
+ }
+
+
+ /// isSimple - Test if the given MVT is simple (as opposed to being
+ /// extended).
+ inline bool isSimple() const {
+ return V <= SimpleTypeMask;
+ }
- /// MVT::ValueType - This type holds low-level value types. Valid values
- /// include any of the values in the SimpleValueType enum, or any value
- /// returned from a function in the MVT namespace that has a ValueType
- /// return type. Any value type equal to one of the SimpleValueType enum
- /// values is a "simple" value type. All other value types are "extended".
- ///
- /// Note that simple doesn't necessary mean legal for the target machine.
- /// All legal value types must be simple, but often there are some simple
- /// value types that are not legal.
- ///
- /// @internal
- /// Extended types are either vector types or arbitrary precision integers.
- /// Arbitrary precision integers have iAny in the first SimpleTypeBits bits,
- /// and the bit-width in the next PrecisionBits bits, offset by minus one.
- /// Vector types are encoded by having the first SimpleTypeBits+PrecisionBits
- /// bits encode the vector element type (which must be a scalar type, possibly
- /// an arbitrary precision integer) and the remaining VectorBits upper bits
- /// encode the vector length, offset by one.
- ///
- /// 31--------------16-----------8-------------0
- /// | Vector length | Precision | Simple type |
- /// | | Vector element |
- ///
- /// Note that the verifier currently requires the top bit to be zero.
-
- typedef uint32_t ValueType;
-
- static const int SimpleTypeBits = 8;
- static const int PrecisionBits = 8;
- static const int VectorBits = 32 - SimpleTypeBits - PrecisionBits;
-
- static const uint32_t SimpleTypeMask =
- (~uint32_t(0) << (32 - SimpleTypeBits)) >> (32 - SimpleTypeBits);
-
- static const uint32_t PrecisionMask =
- ((~uint32_t(0) << VectorBits) >> (32 - PrecisionBits)) << SimpleTypeBits;
-
- static const uint32_t VectorMask =
- (~uint32_t(0) >> (32 - VectorBits)) << (32 - VectorBits);
-
- static const uint32_t ElementMask =
- (~uint32_t(0) << VectorBits) >> VectorBits;
-
- /// MVT::isExtendedVT - Test if the given ValueType is extended
- /// (as opposed to being simple).
- static inline bool isExtendedVT(ValueType VT) {
- return VT > SimpleTypeMask;
- }
-
- /// MVT::isInteger - Return true if this is an integer, or a vector integer
- /// type.
- static inline bool isInteger(ValueType VT) {
- ValueType SVT = VT & SimpleTypeMask;
- return (SVT >= FIRST_INTEGER_VALUETYPE && SVT <= LAST_INTEGER_VALUETYPE) ||
- (SVT >= v8i8 && SVT <= v2i64) || (SVT == iAny && (VT & PrecisionMask));
- }
-
- /// MVT::isFloatingPoint - Return true if this is an FP, or a vector FP type.
- static inline bool isFloatingPoint(ValueType VT) {
- ValueType SVT = VT & SimpleTypeMask;
- return (SVT >= f32 && SVT <= ppcf128) || (SVT >= v2f32 && SVT <= v2f64);
- }
-
- /// MVT::isVector - Return true if this is a vector value type.
- static inline bool isVector(ValueType VT) {
- return (VT >= FIRST_VECTOR_VALUETYPE && VT <= LAST_VECTOR_VALUETYPE) ||
- (VT & VectorMask);
- }
-
- /// MVT::getVectorElementType - Given a vector type, return the type of
- /// each element.
- static inline ValueType getVectorElementType(ValueType VT) {
- assert(isVector(VT) && "Invalid vector type!");
- switch (VT) {
- default:
- assert(isExtendedVT(VT) && "Unknown simple vector type!");
- return VT & ElementMask;
- case v8i8 :
- case v16i8: return i8;
- case v4i16:
- case v8i16: return i16;
- case v2i32:
- case v3i32:
- case v4i32: return i32;
- case v1i64:
- case v2i64: return i64;
- case v2f32:
- case v3f32:
- case v4f32: return f32;
- case v2f64: return f64;
+ /// isExtended - Test if the given MVT is extended (as opposed to
+ /// being simple).
+ inline bool isExtended() const {
+ return !isSimple();
}
- }
-
- /// MVT::getVectorNumElements - Given a vector type, return the
- /// number of elements it contains.
- static inline unsigned getVectorNumElements(ValueType VT) {
- assert(isVector(VT) && "Invalid vector type!");
- switch (VT) {
- default:
- assert(isExtendedVT(VT) && "Unknown simple vector type!");
- return ((VT & VectorMask) >> (32 - VectorBits)) - 1;
- case v16i8: return 16;
- case v8i8 :
- case v8i16: return 8;
- case v4i16:
- case v4i32:
- case v4f32: return 4;
- case v3i32:
- case v3f32: return 3;
- case v2i32:
- case v2i64:
- case v2f32:
- case v2f64: return 2;
- case v1i64: return 1;
+
+ /// isFloatingPoint - Return true if this is a FP, or a vector FP type.
+ inline bool isFloatingPoint() const {
+ uint32_t SVT = V & SimpleTypeMask;
+ return (SVT >= f32 && SVT <= ppcf128) || (SVT >= v2f32 && SVT <= v2f64);
}
- }
-
- /// MVT::getSizeInBits - Return the size of the specified value type
- /// in bits.
- ///
- static inline unsigned getSizeInBits(ValueType VT) {
- switch (VT) {
- default:
- assert(isExtendedVT(VT) && "ValueType has no known size!");
- if (isVector(VT))
- return getSizeInBits(getVectorElementType(VT)) *
- getVectorNumElements(VT);
- if (isInteger(VT))
- return ((VT & PrecisionMask) >> SimpleTypeBits) + 1;
- assert(0 && "Unknown value type!");
- case MVT::i1 : return 1;
- case MVT::i8 : return 8;
- case MVT::i16 : return 16;
- case MVT::f32 :
- case MVT::i32 : return 32;
- case MVT::f64 :
- case MVT::i64 :
- case MVT::v8i8:
- case MVT::v4i16:
- case MVT::v2i32:
- case MVT::v1i64:
- case MVT::v2f32: return 64;
- case MVT::f80 : return 80;
- case MVT::v3i32:
- case MVT::v3f32: return 96;
- case MVT::f128:
- case MVT::ppcf128:
- case MVT::i128:
- case MVT::v16i8:
- case MVT::v8i16:
- case MVT::v4i32:
- case MVT::v2i64:
- case MVT::v4f32:
- case MVT::v2f64: return 128;
+
+ /// isInteger - Return true if this is an integer, or a vector integer type.
+ inline bool isInteger() const {
+ uint32_t SVT = V & SimpleTypeMask;
+ return (SVT >= FIRST_INTEGER_VALUETYPE && SVT <= LAST_INTEGER_VALUETYPE) ||
+ (SVT >= v8i8 && SVT <= v2i64) || (SVT == iAny && (V & PrecisionMask));
}
- }
-
- /// MVT::getStoreSizeInBits - Return the number of bits overwritten by a
- /// store of the specified value type.
- ///
- static inline unsigned getStoreSizeInBits(ValueType VT) {
- return (getSizeInBits(VT) + 7)/8*8;
- }
-
- /// MVT::is64BitVector - Return true if this is a 64-bit vector type.
- static inline bool is64BitVector(ValueType VT) {
- return (VT==v8i8 || VT==v4i16 || VT==v2i32 || VT==v1i64 || VT==v2f32 ||
- (isExtendedVT(VT) && isVector(VT) && getSizeInBits(VT)==64));
- }
-
- /// MVT::is128BitVector - Return true if this is a 128-bit vector type.
- static inline bool is128BitVector(ValueType VT) {
- return (VT==v16i8 || VT==v8i16 || VT==v4i32 || VT==v2i64 ||
- VT==v4f32 || VT==v2f64 ||
- (isExtendedVT(VT) && isVector(VT) && getSizeInBits(VT)==128));
- }
-
- /// MVT::getIntegerType - Returns the ValueType that represents an integer
- /// with the given number of bits.
- ///
- static inline ValueType getIntegerType(unsigned BitWidth) {
- switch (BitWidth) {
- default:
- break;
- case 1:
- return MVT::i1;
- case 8:
- return MVT::i8;
- case 16:
- return MVT::i16;
- case 32:
- return MVT::i32;
- case 64:
- return MVT::i64;
- case 128:
- return MVT::i128;
+
+ /// isVector - Return true if this is a vector value type.
+ inline bool isVector() const {
+ return (V >= FIRST_VECTOR_VALUETYPE && V <= LAST_VECTOR_VALUETYPE) ||
+ (V & VectorMask);
}
- ValueType Result = iAny |
- (((BitWidth - 1) << SimpleTypeBits) & PrecisionMask);
- assert(getSizeInBits(Result) == BitWidth && "Bad bit width!");
- return Result;
- }
-
- /// MVT::RoundIntegerType - Rounds the bit-width of the given integer
- /// ValueType up to the nearest power of two (and at least to eight),
- /// and returns the integer ValueType with that number of bits.
- ///
- static inline ValueType RoundIntegerType(ValueType VT) {
- assert(isInteger(VT) && !isVector(VT) && "Invalid integer type!");
- unsigned BitWidth = getSizeInBits(VT);
- if (BitWidth <= 8)
- return MVT::i8;
- else
- return getIntegerType(1 << Log2_32_Ceil(BitWidth));
- }
-
- /// MVT::getVectorType - Returns the ValueType that represents a vector
- /// NumElements in length, where each element is of type VT.
- ///
- static inline ValueType getVectorType(ValueType VT, unsigned NumElements) {
- switch (VT) {
- default:
- break;
- case MVT::i8:
- if (NumElements == 8) return MVT::v8i8;
- if (NumElements == 16) return MVT::v16i8;
- break;
- case MVT::i16:
- if (NumElements == 4) return MVT::v4i16;
- if (NumElements == 8) return MVT::v8i16;
- break;
- case MVT::i32:
- if (NumElements == 2) return MVT::v2i32;
- if (NumElements == 3) return MVT::v3i32;
- if (NumElements == 4) return MVT::v4i32;
- break;
- case MVT::i64:
- if (NumElements == 1) return MVT::v1i64;
- if (NumElements == 2) return MVT::v2i64;
- break;
- case MVT::f32:
- if (NumElements == 2) return MVT::v2f32;
- if (NumElements == 3) return MVT::v3f32;
- if (NumElements == 4) return MVT::v4f32;
- break;
- case MVT::f64:
- if (NumElements == 2) return MVT::v2f64;
- break;
+
+ /// is64BitVector - Return true if this is a 64-bit vector type.
+ inline bool is64BitVector() const {
+ return (V==v8i8 || V==v4i16 || V==v2i32 || V==v1i64 || V==v2f32 ||
+ (isExtended() && isVector() && getSizeInBits()==64));
}
- // Set the length with the top bit forced to zero (needed by the verifier).
- ValueType Result = VT | (((NumElements + 1) << (33 - VectorBits)) >> 1);
- assert(getVectorElementType(Result) == VT &&
- "Bad vector element type!");
- assert(getVectorNumElements(Result) == NumElements &&
- "Bad vector length!");
- return Result;
- }
-
- /// MVT::getIntVectorWithNumElements - Return any integer vector type that has
- /// the specified number of elements.
- static inline ValueType getIntVectorWithNumElements(unsigned NumElts) {
- switch (NumElts) {
- default: return getVectorType(i8, NumElts);
- case 1: return v1i64;
- case 2: return v2i32;
- case 3: return v3i32;
- case 4: return v4i16;
- case 8: return v8i8;
- case 16: return v16i8;
+
+ /// is128BitVector - Return true if this is a 128-bit vector type.
+ inline bool is128BitVector() const {
+ return (V==v16i8 || V==v8i16 || V==v4i32 || V==v2i64 ||
+ V==v4f32 || V==v2f64 ||
+ (isExtended() && isVector() && getSizeInBits()==128));
}
- }
-
-
- /// MVT::getIntVTBitMask - Return an integer with 1's every place there are
- /// bits in the specified integer value type.
- static inline uint64_t getIntVTBitMask(ValueType VT) {
- assert(isInteger(VT) && !isVector(VT) && "Only applies to int scalars!");
- return ~uint64_t(0UL) >> (64-getSizeInBits(VT));
- }
- /// MVT::getIntVTSignBit - Return an integer with a 1 in the position of the
- /// sign bit for the specified integer value type.
- static inline uint64_t getIntVTSignBit(ValueType VT) {
- assert(isInteger(VT) && !isVector(VT) && "Only applies to int scalars!");
- return uint64_t(1UL) << (getSizeInBits(VT)-1);
- }
-
- /// MVT::getValueTypeString - This function returns value type as a string,
- /// e.g. "i32".
- std::string getValueTypeString(ValueType VT);
-
- /// MVT::getTypeForValueType - This method returns an LLVM type corresponding
- /// to the specified ValueType. For integer types, this returns an unsigned
- /// type. Note that this will abort for types that cannot be represented.
- const Type *getTypeForValueType(ValueType VT);
-
- /// MVT::getValueType - Return the value type corresponding to the specified
- /// type. This returns all pointers as MVT::iPTR. If HandleUnknown is true,
- /// unknown types are returned as Other, otherwise they are invalid.
- ValueType getValueType(const Type *Ty, bool HandleUnknown = false);
-}
+
+
+ /// getSimpleVT - Return the SimpleValueType held in the specified
+ /// simple MVT.
+ inline SimpleValueType getSimpleVT() const {
+ assert(isSimple() && "Expected a SimpleValueType!");
+ return (SimpleValueType)V;
+ }
+
+ /// getVectorElementType - Given a vector type, return the type of
+ /// each element.
+ inline MVT getVectorElementType() const {
+ assert(isVector() && "Invalid vector type!");
+ switch (V) {
+ default: {
+ assert(isExtended() && "Unknown simple vector type!");
+ MVT VT;
+ VT.V = V & ElementMask;
+ return VT;
+ }
+ case v8i8 :
+ case v16i8: return i8;
+ case v4i16:
+ case v8i16: return i16;
+ case v2i32:
+ case v3i32:
+ case v4i32: return i32;
+ case v1i64:
+ case v2i64: return i64;
+ case v2f32:
+ case v3f32:
+ case v4f32: return f32;
+ case v2f64: return f64;
+ }
+ }
+
+ /// getVectorNumElements - Given a vector type, return the number of
+ /// elements it contains.
+ inline unsigned getVectorNumElements() const {
+ assert(isVector() && "Invalid vector type!");
+ switch (V) {
+ default:
+ assert(isExtended() && "Unknown simple vector type!");
+ return ((V & VectorMask) >> (32 - VectorBits)) - 1;
+ case v16i8: return 16;
+ case v8i8 :
+ case v8i16: return 8;
+ case v4i16:
+ case v4i32:
+ case v4f32: return 4;
+ case v3i32:
+ case v3f32: return 3;
+ case v2i32:
+ case v2i64:
+ case v2f32:
+ case v2f64: return 2;
+ case v1i64: return 1;
+ }
+ }
+
+ /// getSizeInBits - Return the size of the specified value type in bits.
+ inline unsigned getSizeInBits() const {
+ switch (V) {
+ default:
+ assert(isExtended() && "MVT has no known size!");
+ if (isVector())
+ return getVectorElementType().getSizeInBits()*getVectorNumElements();
+ if (isInteger())
+ return ((V & PrecisionMask) >> SimpleTypeBits) + 1;
+ assert(false && "Unknown value type!");
+ return 0;
+ case i1 : return 1;
+ case i8 : return 8;
+ case i16 : return 16;
+ case f32 :
+ case i32 : return 32;
+ case f64 :
+ case i64 :
+ case v8i8:
+ case v4i16:
+ case v2i32:
+ case v1i64:
+ case v2f32: return 64;
+ case f80 : return 80;
+ case v3i32:
+ case v3f32: return 96;
+ case f128:
+ case ppcf128:
+ case i128:
+ case v16i8:
+ case v8i16:
+ case v4i32:
+ case v2i64:
+ case v4f32:
+ case v2f64: return 128;
+ }
+ }
+
+ /// getStoreSizeInBits - Return the number of bits overwritten by a store
+ /// of the specified value type.
+ inline unsigned getStoreSizeInBits() const {
+ return (getSizeInBits() + 7)/8*8;
+ }
+
+ /// getRoundIntegerType - Rounds the bit-width of the given integer MVT up
+ /// to the nearest power of two (and at least to eight), and returns the
+ /// integer MVT with that number of bits.
+ inline MVT getRoundIntegerType() const {
+ assert(isInteger() && !isVector() && "Invalid integer type!");
+ unsigned BitWidth = getSizeInBits();
+ if (BitWidth <= 8)
+ return i8;
+ else
+ return getIntegerVT(1 << Log2_32_Ceil(BitWidth));
+ }
+
+ /// getIntegerVTBitMask - Return an integer with 1's every place there are
+ /// bits in the specified integer value type. FIXME: Should return an apint.
+ inline uint64_t getIntegerVTBitMask() const {
+ assert(isInteger() && !isVector() && "Only applies to int scalars!");
+ return ~uint64_t(0UL) >> (64-getSizeInBits());
+ }
+
+ /// getIntegerVTSignBit - Return an integer with a 1 in the position of the
+ /// sign bit for the specified integer value type. FIXME: Should return an
+ /// apint.
+ inline uint64_t getIntegerVTSignBit() const {
+ assert(isInteger() && !isVector() && "Only applies to int scalars!");
+ return uint64_t(1UL) << (getSizeInBits()-1);
+ }
+
+ /// getMVTString - This function returns value type as a string,
+ /// e.g. "i32".
+ std::string getMVTString() const;
+
+ /// getTypeForMVT - This method returns an LLVM type corresponding to the
+ /// specified MVT. For integer types, this returns an unsigned type. Note
+ /// that this will abort for types that cannot be represented.
+ const Type *getTypeForMVT() const;
+
+ /// getMVT - Return the value type corresponding to the specified type.
+ /// This returns all pointers as iPTR. If HandleUnknown is true, unknown
+ /// types are returned as Other, otherwise they are invalid.
+ static MVT getMVT(const Type *Ty, bool HandleUnknown = false);
+ };
} // End llvm namespace