Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:08

0001 //===- NoFolder.h - Constant folding helper ---------------------*- 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 NoFolder class, a helper for IRBuilder.  It provides
0010 // IRBuilder with a set of methods for creating unfolded constants.  This is
0011 // useful for learners trying to understand how LLVM IR works, and who don't
0012 // want details to be hidden by the constant folder.  For general constant
0013 // creation and folding, use ConstantExpr and the routines in
0014 // llvm/Analysis/ConstantFolding.h.
0015 //
0016 // Note: since it is not actually possible to create unfolded constants, this
0017 // class returns instructions rather than constants.
0018 //
0019 //===----------------------------------------------------------------------===//
0020 
0021 #ifndef LLVM_IR_NOFOLDER_H
0022 #define LLVM_IR_NOFOLDER_H
0023 
0024 #include "llvm/ADT/ArrayRef.h"
0025 #include "llvm/IR/Constants.h"
0026 #include "llvm/IR/FMF.h"
0027 #include "llvm/IR/IRBuilderFolder.h"
0028 #include "llvm/IR/InstrTypes.h"
0029 #include "llvm/IR/Instruction.h"
0030 #include "llvm/IR/Instructions.h"
0031 
0032 namespace llvm {
0033 
0034 /// NoFolder - Create "constants" (actually, instructions) with no folding.
0035 class NoFolder final : public IRBuilderFolder {
0036   virtual void anchor();
0037 
0038 public:
0039   explicit NoFolder() = default;
0040 
0041   //===--------------------------------------------------------------------===//
0042   // Value-based folders.
0043   //
0044   // Return an existing value or a constant if the operation can be simplified.
0045   // Otherwise return nullptr.
0046   //===--------------------------------------------------------------------===//
0047 
0048   Value *FoldBinOp(Instruction::BinaryOps Opc, Value *LHS,
0049                    Value *RHS) const override {
0050     return nullptr;
0051   }
0052 
0053   Value *FoldExactBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS,
0054                         bool IsExact) const override {
0055     return nullptr;
0056   }
0057 
0058   Value *FoldNoWrapBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS,
0059                          bool HasNUW, bool HasNSW) const override {
0060     return nullptr;
0061   }
0062 
0063   Value *FoldBinOpFMF(Instruction::BinaryOps Opc, Value *LHS, Value *RHS,
0064                       FastMathFlags FMF) const override {
0065     return nullptr;
0066   }
0067 
0068   Value *FoldUnOpFMF(Instruction::UnaryOps Opc, Value *V,
0069                      FastMathFlags FMF) const override {
0070     return nullptr;
0071   }
0072 
0073   Value *FoldCmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override {
0074     return nullptr;
0075   }
0076 
0077   Value *FoldGEP(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
0078                  GEPNoWrapFlags NW) const override {
0079     return nullptr;
0080   }
0081 
0082   Value *FoldSelect(Value *C, Value *True, Value *False) const override {
0083     return nullptr;
0084   }
0085 
0086   Value *FoldExtractValue(Value *Agg,
0087                           ArrayRef<unsigned> IdxList) const override {
0088     return nullptr;
0089   }
0090 
0091   Value *FoldInsertValue(Value *Agg, Value *Val,
0092                          ArrayRef<unsigned> IdxList) const override {
0093     return nullptr;
0094   }
0095 
0096   Value *FoldExtractElement(Value *Vec, Value *Idx) const override {
0097     return nullptr;
0098   }
0099 
0100   Value *FoldInsertElement(Value *Vec, Value *NewElt,
0101                            Value *Idx) const override {
0102     return nullptr;
0103   }
0104 
0105   Value *FoldShuffleVector(Value *V1, Value *V2,
0106                            ArrayRef<int> Mask) const override {
0107     return nullptr;
0108   }
0109 
0110   Value *FoldCast(Instruction::CastOps Op, Value *V,
0111                   Type *DestTy) const override {
0112     return nullptr;
0113   }
0114 
0115   Value *FoldBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Type *Ty,
0116                              Instruction *FMFSource) const override {
0117     return nullptr;
0118   }
0119 
0120   //===--------------------------------------------------------------------===//
0121   // Cast/Conversion Operators
0122   //===--------------------------------------------------------------------===//
0123 
0124   Instruction *CreatePointerCast(Constant *C, Type *DestTy) const override {
0125     return CastInst::CreatePointerCast(C, DestTy);
0126   }
0127 
0128   Instruction *CreatePointerBitCastOrAddrSpaceCast(
0129       Constant *C, Type *DestTy) const override {
0130     return CastInst::CreatePointerBitCastOrAddrSpaceCast(C, DestTy);
0131   }
0132 };
0133 
0134 } // end namespace llvm
0135 
0136 #endif // LLVM_IR_NOFOLDER_H