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 <cmath>
Include dependency graph for ConstantFolding.cpp:
Go to the source code of this file.
Classes | |
class | TemplateRules< ArgType, SubClassName > |
struct | EmptyRules |
struct | BoolRules |
struct | NullPointerRules |
struct | DirectRules< ConstantClass, BuiltinType, Ty, SuperClass > |
struct | DirectIntRules< ConstantClass, BuiltinType, Ty > |
struct | DirectFPRules< ConstantClass, BuiltinType, Ty > |
Defines | |
#define | DEF_CAST(TYPE, CLASS, CTYPE) |
#define | DEF_CAST(TYPE, CLASS, CTYPE) |
Functions | |
static unsigned | getSize (const Type *Ty) |
Constant * | llvm::ConstantFoldCastInstruction (const Constant *V, const Type *DestTy) |
Constant * | llvm::ConstantFoldSelectInstruction (const Constant *Cond, const Constant *V1, const Constant *V2) |
static int | IdxCompare (Constant *C1, Constant *C2) |
static Instruction::BinaryOps | evaluateRelation (const Constant *V1, const Constant *V2) |
Constant * | llvm::ConstantFoldBinaryInstruction (unsigned Opcode, const Constant *V1, const Constant *V2) |
Constant * | llvm::ConstantFoldGetElementPtr (const Constant *C, const std::vector< Value * > &IdxList) |
|
Value: static Constant *CastTo##TYPE (const ConstantClass *V) { \ return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \ } Definition at line 375 of file ConstantFolding.cpp. |
|
Value: static Constant *CastTo##TYPE (const ConstantBool *V) { \ return CLASS::get(Type::TYPE##Ty, (CTYPE)(bool)V->getValue()); \ } Definition at line 375 of file ConstantFolding.cpp. |
|
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 669 of file ConstantFolding.cpp. References llvm::User::getNumOperands(), llvm::ConstantExpr::getOpcode(), llvm::ConstantExpr::getOperand(), llvm::Value::getType(), IdxCompare(), llvm::Type::isLosslesslyConvertibleTo(), llvm::Constant::isNullValue(), llvm::ISD::SetEQ, llvm::ISD::SetGT, llvm::ISD::SetLT, and llvm::ISD::SetNE. Referenced by llvm::ConstantFoldBinaryInstruction(). |
|
Definition at line 519 of file ConstantFolding.cpp. References llvm::Type::getPrimitiveSize(). 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 635 of file ConstantFolding.cpp. Referenced by evaluateRelation(). |