LLVM 22.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/IR/InstrTypes.h"
26#include <optional>
27
28namespace llvm {
29 template <typename T> class ArrayRef;
30 class Value;
31 class Constant;
32 class Type;
33
34 // Constant fold various types of instruction...
36 ConstantFoldCastInstruction(unsigned opcode, ///< The opcode of the cast
37 Constant *V, ///< The source constant
38 Type *DestTy ///< The destination type
39 );
41 Constant *V2);
43 Constant *Idx);
45 Constant *Elt,
46 Constant *Idx);
48 Constant *V2,
49 ArrayRef<int> Mask);
57 Constant *V1, Constant *V2);
60 Constant *C2);
63 std::optional<ConstantRange> InRange,
65} // End llvm namespace
66
67#endif
#define LLVM_ABI
Definition Compiler.h:213
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
const SmallVectorImpl< MachineOperand > & Cond
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:678
This is an important base class in LLVM.
Definition Constant.h:43
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
LLVM Value Representation.
Definition Value.h:75
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI Constant * ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, Constant *V2)
Attempt to constant fold a select instruction with the specified operands.
LLVM_ABI Constant * ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, Constant *C2)
LLVM_ABI Constant * ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V)
LLVM_ABI Constant * ConstantFoldGetElementPtr(Type *Ty, Constant *C, std::optional< ConstantRange > InRange, ArrayRef< Value * > Idxs)
LLVM_ABI Constant * ConstantFoldExtractValueInstruction(Constant *Agg, ArrayRef< unsigned > Idxs)
Attempt to constant fold an extractvalue instruction with the specified operands and indices.
LLVM_ABI Constant * ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, Constant *Idx)
Attempt to constant fold an insertelement instruction with the specified operands and indices.
LLVM_ABI Constant * ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx)
Attempt to constant fold an extractelement instruction with the specified operands and indices.
LLVM_ABI Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)
LLVM_ABI Constant * ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs)
ConstantFoldInsertValueInstruction - Attempt to constant fold an insertvalue instruction with the spe...
LLVM_ABI Constant * ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, ArrayRef< int > Mask)
Attempt to constant fold a shufflevector instruction with the specified operands and mask.
LLVM_ABI Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)