LLVM  15.0.0git
ConstantFold.h
Go to the documentation of this file.
1 //==-- ConstantFold.h - DL-independent Constant Folding Interface -*- C++ -*-=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the DataLayout-independent constant folding interface.
10 // When possible, the DataLayout-aware constant folding interface in
11 // Analysis/ConstantFolding.h should be preferred.
12 //
13 // These interfaces are used by the ConstantExpr::get* methods to automatically
14 // fold constants when possible.
15 //
16 // These operators may return a null object if they don't know how to perform
17 // the specified operation on the specified constant types.
18 //
19 //===----------------------------------------------------------------------===//
20 
21 #ifndef LLVM_IR_CONSTANTFOLD_H
22 #define LLVM_IR_CONSTANTFOLD_H
23 
24 #include "llvm/ADT/Optional.h"
25 #include "llvm/IR/InstrTypes.h"
26 
27 namespace llvm {
28  template <typename T> class ArrayRef;
29  class Value;
30  class Constant;
31  class Type;
32 
33  // Constant fold various types of instruction...
35  unsigned opcode, ///< The opcode of the cast
36  Constant *V, ///< The source constant
37  Type *DestTy ///< The destination type
38  );
40  Constant *V1, Constant *V2);
43  Constant *Idx);
45  ArrayRef<int> Mask);
47  ArrayRef<unsigned> Idxs);
49  ArrayRef<unsigned> Idxs);
50  Constant *ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V);
51  Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1,
52  Constant *V2);
54  Constant *C1, Constant *C2);
55  Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool InBounds,
56  Optional<unsigned> InRangeIndex,
57  ArrayRef<Value *> Idxs);
58 } // End llvm namespace
59 
60 #endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
Optional.h
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:719
C1
instcombine should handle this C2 when C1
Definition: README.txt:263
llvm::ConstantFoldSelectInstruction
Constant * ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, Constant *V2)
Attempt to constant fold a select instruction with the specified operands.
Definition: ConstantFold.cpp:521
llvm::ConstantFoldExtractValueInstruction
Constant * ConstantFoldExtractValueInstruction(Constant *Agg, ArrayRef< unsigned > Idxs)
Attempt to constant fold an extractvalue instruction with the specified operands and indices.
Definition: ConstantFold.cpp:775
llvm::BitmaskEnumDetail::Mask
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:76
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
InstrTypes.h
llvm::ConstantFoldGetElementPtr
Constant * ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool InBounds, Optional< unsigned > InRangeIndex, ArrayRef< Value * > Idxs)
Definition: ConstantFold.cpp:2022
llvm::ConstantFoldBinaryInstruction
Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)
Definition: ConstantFold.cpp:872
llvm::ConstantFoldExtractElementInstruction
Constant * ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx)
Attempt to constant fold an extractelement instruction with the specified operands and indices.
Definition: ConstantFold.cpp:610
llvm::ConstantFoldCastInstruction
Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)
Definition: ConstantFold.cpp:350
llvm::PPC::Predicate
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
Definition: PPCPredicates.h:26
llvm::ConstantFoldCompareInstruction
Constant * ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, Constant *C2)
Definition: ConstantFold.cpp:1572
llvm::ConstantFoldInsertValueInstruction
Constant * ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs)
ConstantFoldInsertValueInstruction - Attempt to constant fold an insertvalue instruction with the spe...
Definition: ConstantFold.cpp:787
TemplateParamKind::Type
@ Type
llvm::ConstantFoldInsertElementInstruction
Constant * ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, Constant *Idx)
Attempt to constant fold an insertelement instruction with the specified operands and indices.
Definition: ConstantFold.cpp:674
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:137
llvm::NVPTX::PTXLdStInstCode::V2
@ V2
Definition: NVPTX.h:123
llvm::ConstantFoldShuffleVectorInstruction
Constant * ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, ArrayRef< int > Mask)
Attempt to constant fold a shufflevector instruction with the specified operands and mask.
Definition: ConstantFold.cpp:716
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::ConstantFoldUnaryInstruction
Constant * ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V)
Definition: ConstantFold.cpp:816