diff options
| author | Chris Lattner <sabre@nondot.org> | 2001-09-09 23:01:47 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2001-09-09 23:01:47 +0000 |
| commit | a461b052073d6c52ffdef1625acf54506a2d6915 (patch) | |
| tree | bdbda38c72865e5e46826137bc85d1b6d3d0e76d /llvm/lib/CodeGen/TargetMachine/Sparc | |
| parent | e4fe7bc4a5917b17c288c8f43b446d91388ef91e (diff) | |
| download | bcm5719-llvm-a461b052073d6c52ffdef1625acf54506a2d6915.tar.gz bcm5719-llvm-a461b052073d6c52ffdef1625acf54506a2d6915.zip | |
Implement the subset of the GetConstantValueAsSignedInt function that is needed, locally. Remove the two support functions to inline their contents.
llvm-svn: 525
Diffstat (limited to 'llvm/lib/CodeGen/TargetMachine/Sparc')
| -rw-r--r-- | llvm/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp b/llvm/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp index 8f79f6674d2..8b5a2806345 100644 --- a/llvm/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp +++ b/llvm/lib/CodeGen/TargetMachine/Sparc/SparcInstrSelection.cpp @@ -107,6 +107,38 @@ static void ForwardOperand (InstructionNode* treeNode, //************************ Internal Functions ******************************/ +// Convenience function to get the value of an integer constant, for an +// appropriate integer or non-integer type that can be held in an integer. +// The type of the argument must be the following: +// GetConstantValueAsSignedInt: any of the above, but the value +// must fit into a int64_t. +// +// isValidConstant is set to true if a valid constant was found. +// + +static int64_t GetConstantValueAsSignedInt(const Value *V, + bool &isValidConstant) { + if (!V->isConstant()) { isValidConstant = false; return 0; } + isValidConstant = true; + + if (V->getType() == Type::BoolTy) + return ((ConstPoolBool*)V)->getValue(); + if (V->getType()->isIntegral()) { + if (V->getType()->isSigned()) + return ((ConstPoolSInt*)V)->getValue(); + + assert(V->getType()->isUnsigned()); + uint64_t Val = ((ConstPoolUInt*)V)->getValue(); + + if (Val < INT64_MAX) // then safe to cast to signed + return (int64_t)Val; + } + + isValidConstant = false; + return 0; +} + + //------------------------------------------------------------------------ // External Function: ThisIsAChainRule |

