LLVM API Documentation

ConstantFold.h
Go to the documentation of this file.
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 LLVM_LIB_IR_CONSTANTFOLD_H
00020 #define LLVM_LIB_IR_CONSTANTFOLD_H
00021 
00022 #include "llvm/ADT/ArrayRef.h"
00023 
00024 namespace llvm {
00025   class Value;
00026   class Constant;
00027   class Type;
00028 
00029   // Constant fold various types of instruction...
00030   Constant *ConstantFoldCastInstruction(
00031     unsigned opcode,     ///< The opcode of the cast
00032     Constant *V,         ///< The source constant
00033     Type *DestTy   ///< The destination type
00034   );
00035   Constant *ConstantFoldSelectInstruction(Constant *Cond,
00036                                           Constant *V1, Constant *V2);
00037   Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx);
00038   Constant *ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt,
00039                                                  Constant *Idx);
00040   Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2,
00041                                                  Constant *Mask);
00042   Constant *ConstantFoldExtractValueInstruction(Constant *Agg,
00043                                                 ArrayRef<unsigned> Idxs);
00044   Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val,
00045                                                ArrayRef<unsigned> Idxs);
00046   Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1,
00047                                           Constant *V2);
00048   Constant *ConstantFoldCompareInstruction(unsigned short predicate, 
00049                                            Constant *C1, Constant *C2);
00050   Constant *ConstantFoldGetElementPtr(Constant *C, bool inBounds,
00051                                       ArrayRef<Constant *> Idxs);
00052   Constant *ConstantFoldGetElementPtr(Constant *C, bool inBounds,
00053                                       ArrayRef<Value *> Idxs);
00054 } // End llvm namespace
00055 
00056 #endif