2004-01-12 22:13:12 +01:00
|
|
|
//===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===//
|
2005-04-22 01:48:37 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2005-04-22 01:48:37 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 22:29:01 +02:00
|
|
|
//
|
2004-01-12 22:13:12 +01:00
|
|
|
// 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.
|
|
|
|
//
|
2008-08-01 14:23:49 +02:00
|
|
|
// These operators may return a null object if they don't know how to perform
|
|
|
|
// the specified operation on the specified constant types.
|
2001-06-06 22:29:01 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 18:26:38 +02:00
|
|
|
#ifndef LLVM_LIB_IR_CONSTANTFOLD_H
|
|
|
|
#define LLVM_LIB_IR_CONSTANTFOLD_H
|
2001-06-06 22:29:01 +02:00
|
|
|
|
2016-11-10 23:34:55 +01:00
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
2016-04-18 11:17:29 +02:00
|
|
|
template <typename T> class ArrayRef;
|
2004-10-12 00:52:25 +02:00
|
|
|
class Value;
|
2004-01-12 22:02:29 +01:00
|
|
|
class Constant;
|
2004-10-27 18:14:51 +02:00
|
|
|
class Type;
|
2005-04-22 01:48:37 +02:00
|
|
|
|
2004-01-12 22:13:12 +01:00
|
|
|
// Constant fold various types of instruction...
|
2006-11-27 02:05:10 +01:00
|
|
|
Constant *ConstantFoldCastInstruction(
|
|
|
|
unsigned opcode, ///< The opcode of the cast
|
2009-09-20 03:35:59 +02:00
|
|
|
Constant *V, ///< The source constant
|
2011-07-18 06:54:35 +02:00
|
|
|
Type *DestTy ///< The destination type
|
2006-11-27 02:05:10 +01:00
|
|
|
);
|
2010-02-01 21:48:08 +01:00
|
|
|
Constant *ConstantFoldSelectInstruction(Constant *Cond,
|
2009-09-20 03:35:59 +02:00
|
|
|
Constant *V1, Constant *V2);
|
2010-02-01 21:48:08 +01:00
|
|
|
Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx);
|
|
|
|
Constant *ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt,
|
2009-09-20 03:35:59 +02:00
|
|
|
Constant *Idx);
|
2010-02-01 21:48:08 +01:00
|
|
|
Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2,
|
2020-03-31 22:08:59 +02:00
|
|
|
ArrayRef<int> Mask);
|
2010-02-01 21:48:08 +01:00
|
|
|
Constant *ConstantFoldExtractValueInstruction(Constant *Agg,
|
2011-07-13 12:26:04 +02:00
|
|
|
ArrayRef<unsigned> Idxs);
|
2010-02-01 21:48:08 +01:00
|
|
|
Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val,
|
2011-07-13 12:26:04 +02:00
|
|
|
ArrayRef<unsigned> Idxs);
|
2019-05-05 18:07:09 +02:00
|
|
|
Constant *ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V);
|
2010-02-01 21:48:08 +01:00
|
|
|
Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1,
|
2009-09-20 03:35:59 +02:00
|
|
|
Constant *V2);
|
2016-03-22 05:37:32 +01:00
|
|
|
Constant *ConstantFoldCompareInstruction(unsigned short predicate,
|
2009-09-20 03:35:59 +02:00
|
|
|
Constant *C1, Constant *C2);
|
2016-11-10 23:34:55 +01:00
|
|
|
Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool InBounds,
|
|
|
|
Optional<unsigned> InRangeIndex,
|
2015-05-07 19:28:58 +02:00
|
|
|
ArrayRef<Value *> Idxs);
|
2015-06-23 11:49:53 +02:00
|
|
|
} // End llvm namespace
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2001-06-06 22:29:01 +02:00
|
|
|
#endif
|