Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
NoFolder.h
Go to the documentation of this file.
1//===- NoFolder.h - Constant folding helper ---------------------*- 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 NoFolder class, a helper for IRBuilder. It provides
10// IRBuilder with a set of methods for creating unfolded constants. This is
11// useful for learners trying to understand how LLVM IR works, and who don't
12// want details to be hidden by the constant folder. For general constant
13// creation and folding, use ConstantExpr and the routines in
14// llvm/Analysis/ConstantFolding.h.
15//
16// Note: since it is not actually possible to create unfolded constants, this
17// class returns instructions rather than constants.
18//
19//===----------------------------------------------------------------------===//
20
21#ifndef LLVM_IR_NOFOLDER_H
22#define LLVM_IR_NOFOLDER_H
23
24#include "llvm/ADT/ArrayRef.h"
25#include "llvm/IR/Constants.h"
26#include "llvm/IR/FMF.h"
28#include "llvm/IR/InstrTypes.h"
29#include "llvm/IR/Instruction.h"
32
33namespace llvm {
34
35/// NoFolder - Create "constants" (actually, instructions) with no folding.
36class LLVM_ABI NoFolder final : public IRBuilderFolder {
38
39public:
40 explicit NoFolder() = default;
41
42 //===--------------------------------------------------------------------===//
43 // Value-based folders.
44 //
45 // Return an existing value or a constant if the operation can be simplified.
46 // Otherwise return nullptr.
47 //===--------------------------------------------------------------------===//
48
50 Value *RHS) const override {
51 return nullptr;
52 }
53
55 bool IsExact) const override {
56 return nullptr;
57 }
58
60 bool HasNUW, bool HasNSW) const override {
61 return nullptr;
62 }
63
65 FastMathFlags FMF) const override {
66 return nullptr;
67 }
68
70 FastMathFlags FMF) const override {
71 return nullptr;
72 }
73
75 return nullptr;
76 }
77
79 GEPNoWrapFlags NW) const override {
80 return nullptr;
81 }
82
83 Value *FoldSelect(Value *C, Value *True, Value *False) const override {
84 return nullptr;
85 }
86
88 ArrayRef<unsigned> IdxList) const override {
89 return nullptr;
90 }
91
93 ArrayRef<unsigned> IdxList) const override {
94 return nullptr;
95 }
96
97 Value *FoldExtractElement(Value *Vec, Value *Idx) const override {
98 return nullptr;
99 }
100
102 Value *Idx) const override {
103 return nullptr;
104 }
105
107 ArrayRef<int> Mask) const override {
108 return nullptr;
109 }
110
112 Type *DestTy) const override {
113 return nullptr;
114 }
115
117 Instruction *FMFSource) const override {
118 return nullptr;
119 }
120
121 //===--------------------------------------------------------------------===//
122 // Cast/Conversion Operators
123 //===--------------------------------------------------------------------===//
124
125 Instruction *CreatePointerCast(Constant *C, Type *DestTy) const override {
126 return CastInst::CreatePointerCast(C, DestTy);
127 }
128
133};
134
135} // end namespace llvm
136
137#endif // LLVM_IR_NOFOLDER_H
#define LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION()
\macro LLVM_VIRTUAL_ANCHOR_FUNCTION This macro is used to adhere to LLVM's policy that each class wit...
Definition Compiler.h:737
#define LLVM_ABI
Definition Compiler.h:213
This file contains the declarations for the subclasses of Constant, which represent the different fla...
#define P(N)
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
static LLVM_ABI CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast or an AddrSpaceCast cast instruction.
static LLVM_ABI CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
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
This provides a helper for copying FMF from an instruction or setting specified flags.
Definition IRBuilder.h:93
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:22
Represents flags for the getelementptr instruction/expression.
IRBuilderFolder - Interface for constant folding in IRBuilder.
Value * FoldShuffleVector(Value *V1, Value *V2, ArrayRef< int > Mask) const override
Definition NoFolder.h:106
Value * FoldExactBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool IsExact) const override
Definition NoFolder.h:54
Value * FoldSelect(Value *C, Value *True, Value *False) const override
Definition NoFolder.h:83
Value * FoldBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS) const override
Definition NoFolder.h:49
Value * FoldInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > IdxList) const override
Definition NoFolder.h:92
Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, GEPNoWrapFlags NW) const override
Definition NoFolder.h:78
Value * FoldBinOpFMF(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, FastMathFlags FMF) const override
Definition NoFolder.h:64
Value * FoldCast(Instruction::CastOps Op, Value *V, Type *DestTy) const override
Definition NoFolder.h:111
Value * FoldNoWrapBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool HasNUW, bool HasNSW) const override
Definition NoFolder.h:59
Instruction * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const override
Definition NoFolder.h:129
Value * FoldExtractElement(Value *Vec, Value *Idx) const override
Definition NoFolder.h:97
Value * FoldCmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override
Definition NoFolder.h:74
Instruction * CreatePointerCast(Constant *C, Type *DestTy) const override
Definition NoFolder.h:125
Value * FoldInsertElement(Value *Vec, Value *NewElt, Value *Idx) const override
Definition NoFolder.h:101
Value * FoldBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, Value *RHS, Type *Ty, Instruction *FMFSource) const override
Definition NoFolder.h:116
Value * FoldExtractValue(Value *Agg, ArrayRef< unsigned > IdxList) const override
Definition NoFolder.h:87
NoFolder()=default
Value * FoldUnOpFMF(Instruction::UnaryOps Opc, Value *V, FastMathFlags FMF) const override
Definition NoFolder.h:69
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
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op