LLVM API Documentation
00001 //===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the (internal) constant folding interfaces for LLVM. These 00011 // interfaces are used by the ConstantExpr::get* methods to automatically fold 00012 // constants when possible. 00013 // 00014 // These operators may return a null object if they don't know how to perform 00015 // the specified operation on the specified constant types. 00016 // 00017 //===----------------------------------------------------------------------===// 00018 00019 #ifndef CONSTANTFOLDING_H 00020 #define CONSTANTFOLDING_H 00021 00022 namespace llvm { 00023 class Value; 00024 class Constant; 00025 class Type; 00026 00027 // Constant fold various types of instruction... 00028 Constant *ConstantFoldCastInstruction( 00029 unsigned opcode, ///< The opcode of the cast 00030 const Constant *V, ///< The source constant 00031 const Type *DestTy ///< The destination type 00032 ); 00033 Constant *ConstantFoldSelectInstruction(const Constant *Cond, 00034 const Constant *V1, 00035 const Constant *V2); 00036 Constant *ConstantFoldExtractElementInstruction(const Constant *Val, 00037 const Constant *Idx); 00038 Constant *ConstantFoldInsertElementInstruction(const Constant *Val, 00039 const Constant *Elt, 00040 const Constant *Idx); 00041 Constant *ConstantFoldShuffleVectorInstruction(const Constant *V1, 00042 const Constant *V2, 00043 const Constant *Mask); 00044 Constant *ConstantFoldExtractValueInstruction(const Constant *Agg, 00045 const unsigned *Idxs, 00046 unsigned NumIdx); 00047 Constant *ConstantFoldInsertValueInstruction(const Constant *Agg, 00048 const Constant *Val, 00049 const unsigned* Idxs, 00050 unsigned NumIdx); 00051 Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1, 00052 const Constant *V2); 00053 Constant *ConstantFoldCompareInstruction(unsigned short predicate, 00054 const Constant *C1, 00055 const Constant *C2); 00056 Constant *ConstantFoldGetElementPtr(const Constant *C, 00057 Constant* const *Idxs, unsigned NumIdx); 00058 } // End llvm namespace 00059 00060 #endif