ConstantFold.h revision 7fc52e2d95ffa543288a2fef7ef1346ce14b1a61
1cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner//===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===// 2fd93908ae8b9684fe71c239e3c6cfe13ff6a2663Misha Brukman// 36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// The LLVM Compiler Infrastructure 46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 54ee451de366474b9c228b4e5fa573795a715216dChris Lattner// This file is distributed under the University of Illinois Open Source 64ee451de366474b9c228b4e5fa573795a715216dChris Lattner// License. See LICENSE.TXT for details. 7fd93908ae8b9684fe71c239e3c6cfe13ff6a2663Misha Brukman// 86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===// 9009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner// 10cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner// This file defines the (internal) constant folding interfaces for LLVM. These 11cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner// interfaces are used by the ConstantExpr::get* methods to automatically fold 12cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner// constants when possible. 13cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner// 1458921feaa9340fb32e2a01ef3cdca6caf8b71e1cDuncan Sands// These operators may return a null object if they don't know how to perform 1558921feaa9340fb32e2a01ef3cdca6caf8b71e1cDuncan Sands// the specified operation on the specified constant types. 16009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner// 17009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner//===----------------------------------------------------------------------===// 18009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 19cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner#ifndef CONSTANTFOLDING_H 20cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner#define CONSTANTFOLDING_H 21009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner 22fc6d3a49867cd38954dc40936a88f1907252c6d2Jay Foad#include "llvm/ADT/ArrayRef.h" 23fc6d3a49867cd38954dc40936a88f1907252c6d2Jay Foad 24d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm { 257fa6e666ece60455cf9d75eff6e6915bebf05cbcChris Lattner class Value; 268b0f0cb9088a7746fea2ba23821e50d87cef4a56Chris Lattner class Constant; 271fca5ff62bb2ecb5bfc8974f4dbfc56e9d3ca721Chris Lattner class Type; 28fd93908ae8b9684fe71c239e3c6cfe13ff6a2663Misha Brukman 29cbfd40654177d6c2b7fcb94272c3a8064d5b8297Chris Lattner // Constant fold various types of instruction... 303da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer Constant *ConstantFoldCastInstruction( 313da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer unsigned opcode, ///< The opcode of the cast 3233c06adcf10d3ef7bbfc70f09f4966eec2e6c85eNick Lewycky Constant *V, ///< The source constant 33db125cfaf57cc83e7dd7453de2d509bc8efd0e5eChris Lattner Type *DestTy ///< The destination type 343da59db637a887474c1b1346c1f3ccf53b6c4663Reid Spencer ); 35b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldSelectInstruction(Constant *Cond, 3633c06adcf10d3ef7bbfc70f09f4966eec2e6c85eNick Lewycky Constant *V1, Constant *V2); 37b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx); 38b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, 3933c06adcf10d3ef7bbfc70f09f4966eec2e6c85eNick Lewycky Constant *Idx); 40b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, 4133c06adcf10d3ef7bbfc70f09f4966eec2e6c85eNick Lewycky Constant *Mask); 42b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldExtractValueInstruction(Constant *Agg, 43fc6d3a49867cd38954dc40936a88f1907252c6d2Jay Foad ArrayRef<unsigned> Idxs); 44b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, 45fc6d3a49867cd38954dc40936a88f1907252c6d2Jay Foad ArrayRef<unsigned> Idxs); 46b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, 4733c06adcf10d3ef7bbfc70f09f4966eec2e6c85eNick Lewycky Constant *V2); 48b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldCompareInstruction(unsigned short predicate, 4933c06adcf10d3ef7bbfc70f09f4966eec2e6c85eNick Lewycky Constant *C1, Constant *C2); 50b29d596072d2ba32a0bb59241baf7a1c0ff5ed94Chris Lattner Constant *ConstantFoldGetElementPtr(Constant *C, bool inBounds, 517fc52e2d95ffa543288a2fef7ef1346ce14b1a61Jay Foad ArrayRef<Constant *> Idxs); 5225052d8d64f18a85d6a84e0e010f6ba3eba0760dJay Foad Constant *ConstantFoldGetElementPtr(Constant *C, bool inBounds, 537fc52e2d95ffa543288a2fef7ef1346ce14b1a61Jay Foad ArrayRef<Value *> Idxs); 54d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace 55d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 56009505452b713ed2e3a8e99c5545a6e721c65495Chris Lattner#endif 57