|
|
|||
File indexing completed on 2026-05-10 08:44:45
0001 //===- VNCoercion.h - Value Numbering Coercion Utilities --------*- 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 /// \file / This file provides routines used by LLVM's value numbering passes to 0009 /// perform various forms of value extraction from memory when the types are not 0010 /// identical. For example, given 0011 /// 0012 /// store i32 8, i32 *%foo 0013 /// %a = bitcast i32 *%foo to i16 0014 /// %val = load i16, i16 *%a 0015 /// 0016 /// It possible to extract the value of the load of %a from the store to %foo. 0017 /// These routines know how to tell whether they can do that (the analyze* 0018 /// routines), and can also insert the necessary IR to do it (the get* 0019 /// routines). 0020 0021 #ifndef LLVM_TRANSFORMS_UTILS_VNCOERCION_H 0022 #define LLVM_TRANSFORMS_UTILS_VNCOERCION_H 0023 0024 namespace llvm { 0025 class Constant; 0026 class StoreInst; 0027 class LoadInst; 0028 class MemIntrinsic; 0029 class Instruction; 0030 class IRBuilderBase; 0031 class Value; 0032 class Type; 0033 class DataLayout; 0034 namespace VNCoercion { 0035 /// Return true if CoerceAvailableValueToLoadType would succeed if it was 0036 /// called. 0037 bool canCoerceMustAliasedValueToLoad(Value *StoredVal, Type *LoadTy, 0038 const DataLayout &DL); 0039 0040 /// If we saw a store of a value to memory, and then a load from a must-aliased 0041 /// pointer of a different type, try to coerce the stored value to the loaded 0042 /// type. LoadedTy is the type of the load we want to replace. IRB is 0043 /// IRBuilder used to insert new instructions. 0044 /// 0045 /// If we can't do it, return null. 0046 Value *coerceAvailableValueToLoadType(Value *StoredVal, Type *LoadedTy, 0047 IRBuilderBase &IRB, const DataLayout &DL); 0048 0049 /// This function determines whether a value for the pointer LoadPtr can be 0050 /// extracted from the store at DepSI. 0051 /// 0052 /// On success, it returns the offset into DepSI that extraction would start. 0053 /// On failure, it returns -1. 0054 int analyzeLoadFromClobberingStore(Type *LoadTy, Value *LoadPtr, 0055 StoreInst *DepSI, const DataLayout &DL); 0056 0057 /// This function determines whether a value for the pointer LoadPtr can be 0058 /// extracted from the load at DepLI. 0059 /// 0060 /// On success, it returns the offset into DepLI that extraction would start. 0061 /// On failure, it returns -1. 0062 int analyzeLoadFromClobberingLoad(Type *LoadTy, Value *LoadPtr, LoadInst *DepLI, 0063 const DataLayout &DL); 0064 0065 /// This function determines whether a value for the pointer LoadPtr can be 0066 /// extracted from the memory intrinsic at DepMI. 0067 /// 0068 /// On success, it returns the offset into DepMI that extraction would start. 0069 /// On failure, it returns -1. 0070 int analyzeLoadFromClobberingMemInst(Type *LoadTy, Value *LoadPtr, 0071 MemIntrinsic *DepMI, const DataLayout &DL); 0072 0073 /// If analyzeLoadFromClobberingStore/Load returned an offset, this function 0074 /// can be used to actually perform the extraction of the bits from the store. 0075 /// It inserts instructions to do so at InsertPt, and returns the extracted 0076 /// value. 0077 Value *getValueForLoad(Value *SrcVal, unsigned Offset, Type *LoadTy, 0078 Instruction *InsertPt, const DataLayout &DL); 0079 // This is the same as getValueForLoad, except it performs no insertion. 0080 // It only allows constant inputs. 0081 Constant *getConstantValueForLoad(Constant *SrcVal, unsigned Offset, 0082 Type *LoadTy, const DataLayout &DL); 0083 0084 /// If analyzeLoadFromClobberingMemInst returned an offset, this function can be 0085 /// used to actually perform the extraction of the bits from the memory 0086 /// intrinsic. It inserts instructions to do so at InsertPt, and returns the 0087 /// extracted value. 0088 Value *getMemInstValueForLoad(MemIntrinsic *SrcInst, unsigned Offset, 0089 Type *LoadTy, Instruction *InsertPt, 0090 const DataLayout &DL); 0091 // This is the same as getStoreValueForLoad, except it performs no insertion. 0092 // It returns nullptr if it cannot produce a constant. 0093 Constant *getConstantMemInstValueForLoad(MemIntrinsic *SrcInst, unsigned Offset, 0094 Type *LoadTy, const DataLayout &DL); 0095 } 0096 } 0097 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|