Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:57

0001 //==-- ConstantFold.h - DL-independent Constant Folding Interface -*- C++ -*-=//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the DataLayout-independent constant folding interface.
0010 // When possible, the DataLayout-aware constant folding interface in
0011 // Analysis/ConstantFolding.h should be preferred.
0012 //
0013 // These interfaces are used by the ConstantExpr::get* methods to automatically
0014 // fold constants when possible.
0015 //
0016 // These operators may return a null object if they don't know how to perform
0017 // the specified operation on the specified constant types.
0018 //
0019 //===----------------------------------------------------------------------===//
0020 
0021 #ifndef LLVM_IR_CONSTANTFOLD_H
0022 #define LLVM_IR_CONSTANTFOLD_H
0023 
0024 #include "llvm/IR/InstrTypes.h"
0025 #include <optional>
0026 
0027 namespace llvm {
0028   template <typename T> class ArrayRef;
0029   class Value;
0030   class Constant;
0031   class Type;
0032 
0033   // Constant fold various types of instruction...
0034   Constant *ConstantFoldCastInstruction(
0035     unsigned opcode,     ///< The opcode of the cast
0036     Constant *V,         ///< The source constant
0037     Type *DestTy   ///< The destination type
0038   );
0039   Constant *ConstantFoldSelectInstruction(Constant *Cond,
0040                                           Constant *V1, Constant *V2);
0041   Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx);
0042   Constant *ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt,
0043                                                  Constant *Idx);
0044   Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2,
0045                                                  ArrayRef<int> Mask);
0046   Constant *ConstantFoldExtractValueInstruction(Constant *Agg,
0047                                                 ArrayRef<unsigned> Idxs);
0048   Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val,
0049                                                ArrayRef<unsigned> Idxs);
0050   Constant *ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V);
0051   Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1,
0052                                           Constant *V2);
0053   Constant *ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
0054                                            Constant *C1, Constant *C2);
0055   Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C,
0056                                       std::optional<ConstantRange> InRange,
0057                                       ArrayRef<Value *> Idxs);
0058 } // End llvm namespace
0059 
0060 #endif