InstructionSimplify.h revision e34537856a544c83513e390ac9552a8bc3823346
1//===-- InstructionSimplify.h - Fold instructions into simpler forms ------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file declares routines for folding instructions into simpler forms that 11// do not require creating new instructions. For example, this does constant 12// folding, and can handle identities like (X&0)->0. 13// 14//===----------------------------------------------------------------------===// 15 16#ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H 17#define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H 18 19namespace llvm { 20 class Instruction; 21 class Value; 22 class TargetData; 23 24 /// SimplifyAndInst - Given operands for an And, see if we can 25 /// fold the result. If not, this returns null. 26 Value *SimplifyAndInst(Value *LHS, Value *RHS, 27 const TargetData *TD = 0); 28 29 /// SimplifyOrInst - Given operands for an Or, see if we can 30 /// fold the result. If not, this returns null. 31 Value *SimplifyOrInst(Value *LHS, Value *RHS, 32 const TargetData *TD = 0); 33 34 /// SimplifyICmpInst - Given operands for an ICmpInst, see if we can 35 /// fold the result. If not, this returns null. 36 Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, 37 const TargetData *TD = 0); 38 39 /// SimplifyFCmpInst - Given operands for an FCmpInst, see if we can 40 /// fold the result. If not, this returns null. 41 Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, 42 const TargetData *TD = 0); 43 44 45 //=== Helper functions for higher up the class hierarchy. 46 47 48 /// SimplifyCmpInst - Given operands for a CmpInst, see if we can 49 /// fold the result. If not, this returns null. 50 Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, 51 const TargetData *TD = 0); 52 53 /// SimplifyBinOp - Given operands for a BinaryOperator, see if we can 54 /// fold the result. If not, this returns null. 55 Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, 56 const TargetData *TD = 0); 57 58 /// SimplifyInstruction - See if we can compute a simplified version of this 59 /// instruction. If not, this returns null. 60 Value *SimplifyInstruction(Instruction *I, const TargetData *TD = 0); 61 62} // end namespace llvm 63 64#endif 65 66