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 class LLVMContext; 00027 00028 // Constant fold various types of instruction... 00029 Constant *ConstantFoldCastInstruction( 00030 LLVMContext &Context, 00031 unsigned opcode, ///< The opcode of the cast 00032 const Constant *V, ///< The source constant 00033 const Type *DestTy ///< The destination type 00034 ); 00035 Constant *ConstantFoldSelectInstruction(LLVMContext &Context, 00036 const Constant *Cond, 00037 const Constant *V1, 00038 const Constant *V2); 00039 Constant *ConstantFoldExtractElementInstruction(LLVMContext &Context, 00040 const Constant *Val, 00041 const Constant *Idx); 00042 Constant *ConstantFoldInsertElementInstruction(LLVMContext &Context, 00043 const Constant *Val, 00044 const Constant *Elt, 00045 const Constant *Idx); 00046 Constant *ConstantFoldShuffleVectorInstruction(LLVMContext &Context, 00047 const Constant *V1, 00048 const Constant *V2, 00049 const Constant *Mask); 00050 Constant *ConstantFoldExtractValueInstruction(LLVMContext &Context, 00051 const Constant *Agg, 00052 const unsigned *Idxs, 00053 unsigned NumIdx); 00054 Constant *ConstantFoldInsertValueInstruction(LLVMContext &Context, 00055 const Constant *Agg, 00056 const Constant *Val, 00057 const unsigned* Idxs, 00058 unsigned NumIdx); 00059 Constant *ConstantFoldBinaryInstruction(LLVMContext &Context, 00060 unsigned Opcode, const Constant *V1, 00061 const Constant *V2); 00062 Constant *ConstantFoldCompareInstruction(LLVMContext &Context, 00063 unsigned short predicate, 00064 const Constant *C1, 00065 const Constant *C2); 00066 Constant *ConstantFoldGetElementPtr(LLVMContext &Context, const Constant *C, 00067 Constant* const *Idxs, unsigned NumIdx); 00068 } // End llvm namespace 00069 00070 #endif