blob: e6e65efd03d2a1f3418ee576f2217bd405520779 [file] [log] [blame]
Chris Lattner59cd9f12001-11-04 23:24:06 +00001//===-- TransformInternals.h - Shared functions for Transforms ---*- C++ -*--=//
2//
3// This header file declares shared functions used by the different components
4// of the Transforms library.
5//
6//===----------------------------------------------------------------------===//
7
8#ifndef TRANSFORM_INTERNALS_H
9#define TRANSFORM_INTERNALS_H
10
11#include "llvm/BasicBlock.h"
12#include "llvm/Target/TargetData.h"
13#include <map>
14
15// TargetData Hack: Eventually we will have annotations given to us by the
16// backend so that we know stuff about type size and alignments. For now
17// though, just use this, because it happens to match the model that GCC uses.
18//
19// FIXME: This should use annotations
20//
21extern const TargetData TD;
22
23// losslessCastableTypes - Return true if the types are bitwise equivalent.
24// This predicate returns true if it is possible to cast from one type to
25// another without gaining or losing precision, or altering the bits in any way.
26//
27bool losslessCastableTypes(const Type *T1, const Type *T2);
28
29
30// ReplaceInstWithValue - Replace all uses of an instruction (specified by BI)
31// with a value, then remove and delete the original instruction.
32//
33void ReplaceInstWithValue(BasicBlock::InstListType &BIL,
34 BasicBlock::iterator &BI, Value *V);
35
36// ReplaceInstWithInst - Replace the instruction specified by BI with the
37// instruction specified by I. The original instruction is deleted and BI is
38// updated to point to the new instruction.
39//
40void ReplaceInstWithInst(BasicBlock::InstListType &BIL,
41 BasicBlock::iterator &BI, Instruction *I);
42
43
44// ------------- Expression Conversion ---------------------
45
46typedef map<const Value*, const Type*> ValueTypeCache;
47typedef map<const Value*, Value*> ValueMapCache;
48
49// RetValConvertableToType - Return true if it is possible
50bool RetValConvertableToType(Value *V, const Type *Ty,
51 ValueTypeCache &ConvertedTypes);
52
53void ConvertUsersType(Value *V, Value *NewVal, ValueMapCache &VMC);
54
55
56#endif