LLVM API Documentation
#include "ConstantFolding.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/MathExtras.h"
#include <limits>
#include <cmath>
Include dependency graph for VMCore/ConstantFolding.cpp:
Go to the source code of this file.
#define DEF_CAST | ( | TYPE, | |||
CLASS, | |||||
CTYPE | ) |
Value:
static Constant *CastTo##TYPE (const ConstantClass *V) { \ return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \ }
Definition at line 463 of file VMCore/ConstantFolding.cpp.
#define DEF_CAST | ( | TYPE, | |||
CLASS, | |||||
CTYPE | ) |
Value:
static Constant *CastTo##TYPE (const ConstantBool *V) { \ return CLASS::get(Type::TYPE##Ty, (CTYPE)(bool)V->getValue()); \ }
Definition at line 463 of file VMCore/ConstantFolding.cpp.
static Constant* CastConstantPacked | ( | ConstantPacked * | CP, | |
const PackedType * | DstTy | |||
) | [static] |
CastConstantPacked - Convert the specified ConstantPacked node to the specified packed type. At this point, we know that the elements of the input packed constant are all simple integer or FP values.
Definition at line 628 of file VMCore/ConstantFolding.cpp.
References llvm::BitsToDouble(), llvm::BitsToFloat(), llvm::CallingConv::C, CP, llvm::DoubleToBits(), llvm::FloatToBits(), llvm::SequentialType::getElementType(), llvm::PackedType::getNumElements(), llvm::Constant::getOperand(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::Type::isFloatingPoint(), llvm::Type::isIntegral(), and V.
Referenced by llvm::ConstantFoldCastInstruction().
static Instruction::BinaryOps evaluateRelation | ( | Constant * | V1, | |
Constant * | V2 | |||
) | [static] |
evaluateRelation - This function determines if there is anything we can decide about the two constants provided. This doesn't need to handle simple things like integer comparisons, but should instead handle ConstantExprs and GlobalValuess. If we can determine that the two constants have a particular relation to each other, we should return the corresponding SetCC code, otherwise return Instruction::BinaryOpsEnd.
To simplify this code we canonicalize the relation so that the first operand is always the most "complex" of the two. We consider simple constants (like ConstantInt) to be the simplest, followed by GlobalValues, followed by ConstantExpr's (the most complex).
Definition at line 982 of file VMCore/ConstantFolding.cpp.
References llvm::gep_type_begin(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::User::getNumOperands(), llvm::ConstantExpr::getOpcode(), llvm::Constant::getOperand(), llvm::ConstantExpr::getOperand(), llvm::Value::getType(), IdxCompare(), llvm::Type::isIntegral(), llvm::Constant::isNullValue(), R, and True.
Referenced by llvm::ConstantFoldBinaryInstruction().
static Constant* EvalVectorOp | ( | const ConstantPacked * | V1, | |
const ConstantPacked * | V2, | |||
Constant *(*)(Constant *, Constant *) | FP | |||
) | [static] |
DoVectorOp - Given two packed constants and a function pointer, apply the function pointer to each element pair, producing a new ConstantPacked constant.
Definition at line 339 of file VMCore/ConstantFolding.cpp.
References llvm::User::getNumOperands(), and llvm::Constant::getOperand().
Referenced by ConstantPackedRules::Add(), ConstantPackedRules::And(), ConstantPackedRules::Div(), ConstantPackedRules::Mul(), ConstantPackedRules::Or(), ConstantPackedRules::Rem(), ConstantPackedRules::Shl(), ConstantPackedRules::Shr(), ConstantPackedRules::Sub(), and ConstantPackedRules::Xor().
static unsigned getSize | ( | const Type * | Ty | ) | [static] |
Definition at line 620 of file VMCore/ConstantFolding.cpp.
References llvm::Type::getPrimitiveSize(), and Ty.
Referenced by llvm::ConstantFoldCastInstruction().
IdxCompare - Compare the two constants as though they were getelementptr indices. This allows coersion of the types to be the same thing.
If the two constants are the "same" (after coersion), return 0. If the first is less than the second, return -1, if the second is less than the first, return 1. If the constants are not integral, return -2.
Definition at line 943 of file VMCore/ConstantFolding.cpp.
References isMaybeZeroSizedType().
Referenced by evaluateRelation().
static bool isMaybeZeroSizedType | ( | const Type * | Ty | ) | [static] |
isZeroSizedType - This type is zero sized if its an array or structure of zero sized types. The only leaf zero sized type is an empty structure.
Definition at line 921 of file VMCore/ConstantFolding.cpp.
References Ty.
Referenced by IdxCompare().