[llvm] 20b5f0c - [IR] Export ConstantFold.h header (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 02:32:22 PDT 2022


Author: Nikita Popov
Date: 2022-06-23T11:32:14+02:00
New Revision: 20b5f0c641c98e68d66dbaf882556e14f1fba9b8

URL: https://github.com/llvm/llvm-project/commit/20b5f0c641c98e68d66dbaf882556e14f1fba9b8
DIFF: https://github.com/llvm/llvm-project/commit/20b5f0c641c98e68d66dbaf882556e14f1fba9b8.diff

LOG: [IR] Export ConstantFold.h header (NFC)

This is in preparation for https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
As part of that change, we'll want to invoke some of these constant
folding APIs explicitly, as it won't happen as part of
ConstantExpr::getXYZ() anymore.

Ideally, we'd merge these with the DL-aware constant folding APIs
and only call those, but this is not easily possible for some
current usages (most important IRBuilder, which uses DL-independent
constant folding by default, and some major layering changes would
be needed to change that).

This is basically a reboot of D115035 with different motivation.

Differential Revision: https://reviews.llvm.org/D128213

Added: 
    llvm/include/llvm/IR/ConstantFold.h

Modified: 
    llvm/lib/IR/ConstantFold.cpp
    llvm/lib/IR/Constants.cpp

Removed: 
    llvm/lib/IR/ConstantFold.h


################################################################################
diff  --git a/llvm/lib/IR/ConstantFold.h b/llvm/include/llvm/IR/ConstantFold.h
similarity index 82%
rename from llvm/lib/IR/ConstantFold.h
rename to llvm/include/llvm/IR/ConstantFold.h
index 1aa44f4d21e58..d637a180b0ba6 100644
--- a/llvm/lib/IR/ConstantFold.h
+++ b/llvm/include/llvm/IR/ConstantFold.h
@@ -1,4 +1,4 @@
-//===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===//
+//==-- ConstantFold.h - DL-independent Constant Folding Interface -*- C++ -*-=//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,23 +6,26 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file defines the (internal) constant folding interfaces for LLVM.  These
-// interfaces are used by the ConstantExpr::get* methods to automatically fold
-// constants when possible.
+// This file defines the DataLayout-independent constant folding interface.
+// When possible, the DataLayout-aware constant folding interface in
+// Analysis/ConstantFolding.h should be preferred.
+//
+// These interfaces are used by the ConstantExpr::get* methods to automatically
+// fold constants when possible.
 //
 // These operators may return a null object if they don't know how to perform
 // the specified operation on the specified constant types.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIB_IR_CONSTANTFOLD_H
-#define LLVM_LIB_IR_CONSTANTFOLD_H
+#ifndef LLVM_IR_CONSTANTFOLD_H
+#define LLVM_IR_CONSTANTFOLD_H
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/IR/InstrTypes.h"
 
 namespace llvm {
-template <typename T> class ArrayRef;
+  template <typename T> class ArrayRef;
   class Value;
   class Constant;
   class Type;

diff  --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 8f7dad37773c3..41b4f2919221f 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -16,7 +16,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "ConstantFold.h"
+#include "llvm/IR/ConstantFold.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/Constants.h"

diff  --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index ef39d65d7f0d9..2eb43416c77bc 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -11,12 +11,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/IR/Constants.h"
-#include "ConstantFold.h"
 #include "LLVMContextImpl.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/ConstantFold.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"


        


More information about the llvm-commits mailing list