blob: 5a1cb745a2fedfe566f3020f1216c97fec8bc2ea [file] [log] [blame]
Chris Lattner2f7c9632001-06-06 20:29:01 +00001//===- ConstantHandling.cpp - Implement ConstantHandling.h ----------------===//
2//
3// This file implements the various intrinsic operations, on constant values.
4//
5//===----------------------------------------------------------------------===//
6
Chris Lattneree965ab2002-01-21 23:17:48 +00007#include "llvm/Transforms/Scalar/ConstantHandling.h"
Chris Lattnerd42d4922001-06-30 04:36:40 +00008
Chris Lattner61607ee2001-09-09 21:01:20 +00009AnnotationID ConstRules::AID(AnnotationManager::getID("opt::ConstRules",
10 &ConstRules::find));
11
Chris Lattner2f7c9632001-06-06 20:29:01 +000012//===----------------------------------------------------------------------===//
13// TemplateRules Class
14//===----------------------------------------------------------------------===//
15//
16// TemplateRules - Implement a subclass of ConstRules that provides all
17// operations as noops. All other rules classes inherit from this class so
18// that if functionality is needed in the future, it can simply be added here
19// and to ConstRules without changing anything else...
20//
21// This class also provides subclasses with typesafe implementations of methods
22// so that don't have to do type casting.
23//
24template<class ArgType, class SubClassName>
25class TemplateRules : public ConstRules {
26
27 //===--------------------------------------------------------------------===//
28 // Redirecting functions that cast to the appropriate types
29 //===--------------------------------------------------------------------===//
30
Chris Lattner3462ae32001-12-03 22:26:30 +000031 virtual Constant *op_not(const Constant *V) const {
Chris Lattner2f7c9632001-06-06 20:29:01 +000032 return SubClassName::Not((const ArgType *)V);
33 }
34
35
Chris Lattner3462ae32001-12-03 22:26:30 +000036 virtual Constant *add(const Constant *V1,
37 const Constant *V2) const {
Chris Lattner2f7c9632001-06-06 20:29:01 +000038 return SubClassName::Add((const ArgType *)V1, (const ArgType *)V2);
39 }
40
Chris Lattner3462ae32001-12-03 22:26:30 +000041 virtual Constant *sub(const Constant *V1,
42 const Constant *V2) const {
Chris Lattner2f7c9632001-06-06 20:29:01 +000043 return SubClassName::Sub((const ArgType *)V1, (const ArgType *)V2);
44 }
45
Chris Lattner3462ae32001-12-03 22:26:30 +000046 virtual Constant *mul(const Constant *V1,
47 const Constant *V2) const {
Chris Lattner4f6031f2001-07-20 19:15:36 +000048 return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2);
49 }
Chris Lattneraf259a72002-04-07 08:10:14 +000050 virtual Constant *div(const Constant *V1,
51 const Constant *V2) const {
52 return SubClassName::Div((const ArgType *)V1, (const ArgType *)V2);
53 }
Chris Lattner4f6031f2001-07-20 19:15:36 +000054
Chris Lattner3462ae32001-12-03 22:26:30 +000055 virtual ConstantBool *lessthan(const Constant *V1,
56 const Constant *V2) const {
Chris Lattner2f7c9632001-06-06 20:29:01 +000057 return SubClassName::LessThan((const ArgType *)V1, (const ArgType *)V2);
58 }
59
Chris Lattner55406842001-07-21 19:10:49 +000060 // Casting operators. ick
Chris Lattner3462ae32001-12-03 22:26:30 +000061 virtual ConstantBool *castToBool(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000062 return SubClassName::CastToBool((const ArgType*)V);
63 }
Chris Lattner3462ae32001-12-03 22:26:30 +000064 virtual ConstantSInt *castToSByte(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000065 return SubClassName::CastToSByte((const ArgType*)V);
66 }
Chris Lattner3462ae32001-12-03 22:26:30 +000067 virtual ConstantUInt *castToUByte(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000068 return SubClassName::CastToUByte((const ArgType*)V);
69 }
Chris Lattner3462ae32001-12-03 22:26:30 +000070 virtual ConstantSInt *castToShort(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000071 return SubClassName::CastToShort((const ArgType*)V);
72 }
Chris Lattner3462ae32001-12-03 22:26:30 +000073 virtual ConstantUInt *castToUShort(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000074 return SubClassName::CastToUShort((const ArgType*)V);
75 }
Chris Lattner3462ae32001-12-03 22:26:30 +000076 virtual ConstantSInt *castToInt(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000077 return SubClassName::CastToInt((const ArgType*)V);
78 }
Chris Lattner3462ae32001-12-03 22:26:30 +000079 virtual ConstantUInt *castToUInt(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000080 return SubClassName::CastToUInt((const ArgType*)V);
81 }
Chris Lattner3462ae32001-12-03 22:26:30 +000082 virtual ConstantSInt *castToLong(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000083 return SubClassName::CastToLong((const ArgType*)V);
84 }
Chris Lattner3462ae32001-12-03 22:26:30 +000085 virtual ConstantUInt *castToULong(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000086 return SubClassName::CastToULong((const ArgType*)V);
87 }
Chris Lattner3462ae32001-12-03 22:26:30 +000088 virtual ConstantFP *castToFloat(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000089 return SubClassName::CastToFloat((const ArgType*)V);
90 }
Chris Lattner3462ae32001-12-03 22:26:30 +000091 virtual ConstantFP *castToDouble(const Constant *V) const {
Chris Lattner55406842001-07-21 19:10:49 +000092 return SubClassName::CastToDouble((const ArgType*)V);
93 }
Chris Lattner3462ae32001-12-03 22:26:30 +000094 virtual ConstantPointer *castToPointer(const Constant *V,
95 const PointerType *Ty) const {
Chris Lattner977f0042001-11-01 05:55:13 +000096 return SubClassName::CastToPointer((const ArgType*)V, Ty);
97 }
Chris Lattner55406842001-07-21 19:10:49 +000098
Chris Lattner2f7c9632001-06-06 20:29:01 +000099 //===--------------------------------------------------------------------===//
100 // Default "noop" implementations
101 //===--------------------------------------------------------------------===//
102
Chris Lattner3462ae32001-12-03 22:26:30 +0000103 inline static Constant *Not(const ArgType *V) { return 0; }
Chris Lattner2f7c9632001-06-06 20:29:01 +0000104
Chris Lattner3462ae32001-12-03 22:26:30 +0000105 inline static Constant *Add(const ArgType *V1, const ArgType *V2) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000106 return 0;
107 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000108 inline static Constant *Sub(const ArgType *V1, const ArgType *V2) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000109 return 0;
110 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000111 inline static Constant *Mul(const ArgType *V1, const ArgType *V2) {
Chris Lattner4f6031f2001-07-20 19:15:36 +0000112 return 0;
113 }
Chris Lattneraf259a72002-04-07 08:10:14 +0000114 inline static Constant *Div(const ArgType *V1, const ArgType *V2) {
115 return 0;
116 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000117 inline static ConstantBool *LessThan(const ArgType *V1, const ArgType *V2) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000118 return 0;
119 }
Chris Lattner55406842001-07-21 19:10:49 +0000120
121 // Casting operators. ick
Chris Lattner3462ae32001-12-03 22:26:30 +0000122 inline static ConstantBool *CastToBool (const Constant *V) { return 0; }
123 inline static ConstantSInt *CastToSByte (const Constant *V) { return 0; }
124 inline static ConstantUInt *CastToUByte (const Constant *V) { return 0; }
125 inline static ConstantSInt *CastToShort (const Constant *V) { return 0; }
126 inline static ConstantUInt *CastToUShort(const Constant *V) { return 0; }
127 inline static ConstantSInt *CastToInt (const Constant *V) { return 0; }
128 inline static ConstantUInt *CastToUInt (const Constant *V) { return 0; }
129 inline static ConstantSInt *CastToLong (const Constant *V) { return 0; }
130 inline static ConstantUInt *CastToULong (const Constant *V) { return 0; }
131 inline static ConstantFP *CastToFloat (const Constant *V) { return 0; }
132 inline static ConstantFP *CastToDouble(const Constant *V) { return 0; }
133 inline static ConstantPointer *CastToPointer(const Constant *,
134 const PointerType *) {return 0;}
Chris Lattner2f7c9632001-06-06 20:29:01 +0000135};
136
137
138
139//===----------------------------------------------------------------------===//
140// EmptyRules Class
141//===----------------------------------------------------------------------===//
142//
143// EmptyRules provides a concrete base class of ConstRules that does nothing
144//
Chris Lattner3462ae32001-12-03 22:26:30 +0000145struct EmptyRules : public TemplateRules<Constant, EmptyRules> {
Chris Lattner61607ee2001-09-09 21:01:20 +0000146};
Chris Lattner2f7c9632001-06-06 20:29:01 +0000147
148
149
150//===----------------------------------------------------------------------===//
151// BoolRules Class
152//===----------------------------------------------------------------------===//
153//
154// BoolRules provides a concrete base class of ConstRules for the 'bool' type.
155//
Chris Lattner3462ae32001-12-03 22:26:30 +0000156struct BoolRules : public TemplateRules<ConstantBool, BoolRules> {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000157
Chris Lattner3462ae32001-12-03 22:26:30 +0000158 inline static Constant *Not(const ConstantBool *V) {
159 return ConstantBool::get(!V->getValue());
Chris Lattner2f7c9632001-06-06 20:29:01 +0000160 }
161
Chris Lattner3462ae32001-12-03 22:26:30 +0000162 inline static Constant *Or(const ConstantBool *V1,
163 const ConstantBool *V2) {
164 return ConstantBool::get(V1->getValue() | V2->getValue());
Chris Lattner2f7c9632001-06-06 20:29:01 +0000165 }
166
Chris Lattner3462ae32001-12-03 22:26:30 +0000167 inline static Constant *And(const ConstantBool *V1,
168 const ConstantBool *V2) {
169 return ConstantBool::get(V1->getValue() & V2->getValue());
Chris Lattner2f7c9632001-06-06 20:29:01 +0000170 }
Chris Lattner61607ee2001-09-09 21:01:20 +0000171};
Chris Lattner2f7c9632001-06-06 20:29:01 +0000172
173
174//===----------------------------------------------------------------------===//
Chris Lattner977f0042001-11-01 05:55:13 +0000175// PointerRules Class
176//===----------------------------------------------------------------------===//
177//
178// PointerRules provides a concrete base class of ConstRules for pointer types
179//
Chris Lattner3462ae32001-12-03 22:26:30 +0000180struct PointerRules : public TemplateRules<ConstantPointer, PointerRules> {
181 inline static ConstantBool *CastToBool (const Constant *V) {
182 if (V->isNullValue()) return ConstantBool::False;
Chris Lattner977f0042001-11-01 05:55:13 +0000183 return 0; // Can't const prop other types of pointers
184 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000185 inline static ConstantSInt *CastToSByte (const Constant *V) {
186 if (V->isNullValue()) return ConstantSInt::get(Type::SByteTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000187 return 0; // Can't const prop other types of pointers
188 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000189 inline static ConstantUInt *CastToUByte (const Constant *V) {
190 if (V->isNullValue()) return ConstantUInt::get(Type::UByteTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000191 return 0; // Can't const prop other types of pointers
192 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000193 inline static ConstantSInt *CastToShort (const Constant *V) {
194 if (V->isNullValue()) return ConstantSInt::get(Type::ShortTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000195 return 0; // Can't const prop other types of pointers
196 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000197 inline static ConstantUInt *CastToUShort(const Constant *V) {
198 if (V->isNullValue()) return ConstantUInt::get(Type::UShortTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000199 return 0; // Can't const prop other types of pointers
200 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000201 inline static ConstantSInt *CastToInt (const Constant *V) {
202 if (V->isNullValue()) return ConstantSInt::get(Type::IntTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000203 return 0; // Can't const prop other types of pointers
204 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000205 inline static ConstantUInt *CastToUInt (const Constant *V) {
206 if (V->isNullValue()) return ConstantUInt::get(Type::UIntTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000207 return 0; // Can't const prop other types of pointers
208 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000209 inline static ConstantSInt *CastToLong (const Constant *V) {
210 if (V->isNullValue()) return ConstantSInt::get(Type::LongTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000211 return 0; // Can't const prop other types of pointers
212 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000213 inline static ConstantUInt *CastToULong (const Constant *V) {
214 if (V->isNullValue()) return ConstantUInt::get(Type::ULongTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000215 return 0; // Can't const prop other types of pointers
216 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000217 inline static ConstantFP *CastToFloat (const Constant *V) {
218 if (V->isNullValue()) return ConstantFP::get(Type::FloatTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000219 return 0; // Can't const prop other types of pointers
220 }
Chris Lattner3462ae32001-12-03 22:26:30 +0000221 inline static ConstantFP *CastToDouble(const Constant *V) {
222 if (V->isNullValue()) return ConstantFP::get(Type::DoubleTy, 0);
Chris Lattner977f0042001-11-01 05:55:13 +0000223 return 0; // Can't const prop other types of pointers
224 }
225
Chris Lattner3462ae32001-12-03 22:26:30 +0000226 inline static ConstantPointer *CastToPointer(const ConstantPointer *V,
227 const PointerType *PTy) {
Chris Lattner977f0042001-11-01 05:55:13 +0000228 if (V->isNullValue())
Chris Lattner3462ae32001-12-03 22:26:30 +0000229 return ConstantPointerNull::get(PTy);
Chris Lattner977f0042001-11-01 05:55:13 +0000230 return 0; // Can't const prop other types of pointers
231 }
232};
233
234
235//===----------------------------------------------------------------------===//
Chris Lattner2f7c9632001-06-06 20:29:01 +0000236// DirectRules Class
237//===----------------------------------------------------------------------===//
238//
239// DirectRules provides a concrete base classes of ConstRules for a variety of
240// different types. This allows the C++ compiler to automatically generate our
241// constant handling operations in a typesafe and accurate manner.
242//
Chris Lattner3462ae32001-12-03 22:26:30 +0000243template<class ConstantClass, class BuiltinType, Type **Ty>
Chris Lattner2f7c9632001-06-06 20:29:01 +0000244struct DirectRules
Chris Lattner3462ae32001-12-03 22:26:30 +0000245 : public TemplateRules<ConstantClass,
246 DirectRules<ConstantClass, BuiltinType, Ty> > {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000247
Chris Lattner3462ae32001-12-03 22:26:30 +0000248 inline static Constant *Not(const ConstantClass *V) {
249 return ConstantClass::get(*Ty, !(BuiltinType)V->getValue());;
Chris Lattner2f7c9632001-06-06 20:29:01 +0000250 }
251
Chris Lattner3462ae32001-12-03 22:26:30 +0000252 inline static Constant *Add(const ConstantClass *V1,
253 const ConstantClass *V2) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000254 BuiltinType Result = (BuiltinType)V1->getValue() +
255 (BuiltinType)V2->getValue();
Chris Lattner3462ae32001-12-03 22:26:30 +0000256 return ConstantClass::get(*Ty, Result);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000257 }
258
Chris Lattner3462ae32001-12-03 22:26:30 +0000259 inline static Constant *Sub(const ConstantClass *V1,
260 const ConstantClass *V2) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000261 BuiltinType Result = (BuiltinType)V1->getValue() -
262 (BuiltinType)V2->getValue();
Chris Lattner3462ae32001-12-03 22:26:30 +0000263 return ConstantClass::get(*Ty, Result);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000264 }
265
Chris Lattner3462ae32001-12-03 22:26:30 +0000266 inline static Constant *Mul(const ConstantClass *V1,
267 const ConstantClass *V2) {
Chris Lattner4f6031f2001-07-20 19:15:36 +0000268 BuiltinType Result = (BuiltinType)V1->getValue() *
269 (BuiltinType)V2->getValue();
Chris Lattner3462ae32001-12-03 22:26:30 +0000270 return ConstantClass::get(*Ty, Result);
Chris Lattner4f6031f2001-07-20 19:15:36 +0000271 }
272
Chris Lattneraf259a72002-04-07 08:10:14 +0000273 inline static Constant *Div(const ConstantClass *V1,
274 const ConstantClass *V2) {
275 BuiltinType Result = (BuiltinType)V1->getValue() /
276 (BuiltinType)V2->getValue();
277 return ConstantClass::get(*Ty, Result);
278 }
279
Chris Lattner3462ae32001-12-03 22:26:30 +0000280 inline static ConstantBool *LessThan(const ConstantClass *V1,
281 const ConstantClass *V2) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000282 bool Result = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue();
Chris Lattner3462ae32001-12-03 22:26:30 +0000283 return ConstantBool::get(Result);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000284 }
Chris Lattner55406842001-07-21 19:10:49 +0000285
Chris Lattner3462ae32001-12-03 22:26:30 +0000286 inline static ConstantPointer *CastToPointer(const ConstantClass *V,
287 const PointerType *PTy) {
Chris Lattner977f0042001-11-01 05:55:13 +0000288 if (V->isNullValue()) // Is it a FP or Integral null value?
Chris Lattner3462ae32001-12-03 22:26:30 +0000289 return ConstantPointerNull::get(PTy);
Chris Lattner977f0042001-11-01 05:55:13 +0000290 return 0; // Can't const prop other types of pointers
291 }
292
Chris Lattner55406842001-07-21 19:10:49 +0000293 // Casting operators. ick
294#define DEF_CAST(TYPE, CLASS, CTYPE) \
Chris Lattner3462ae32001-12-03 22:26:30 +0000295 inline static CLASS *CastTo##TYPE (const ConstantClass *V) { \
Chris Lattnerbbb22962001-09-07 16:40:34 +0000296 return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \
Chris Lattner55406842001-07-21 19:10:49 +0000297 }
298
Chris Lattner3462ae32001-12-03 22:26:30 +0000299 DEF_CAST(Bool , ConstantBool, bool)
300 DEF_CAST(SByte , ConstantSInt, signed char)
301 DEF_CAST(UByte , ConstantUInt, unsigned char)
302 DEF_CAST(Short , ConstantSInt, signed short)
303 DEF_CAST(UShort, ConstantUInt, unsigned short)
304 DEF_CAST(Int , ConstantSInt, signed int)
305 DEF_CAST(UInt , ConstantUInt, unsigned int)
306 DEF_CAST(Long , ConstantSInt, int64_t)
307 DEF_CAST(ULong , ConstantUInt, uint64_t)
308 DEF_CAST(Float , ConstantFP , float)
309 DEF_CAST(Double, ConstantFP , double)
Chris Lattner55406842001-07-21 19:10:49 +0000310#undef DEF_CAST
Chris Lattner2f7c9632001-06-06 20:29:01 +0000311};
312
313//===----------------------------------------------------------------------===//
314// DirectRules Subclasses
315//===----------------------------------------------------------------------===//
316//
317// Given the DirectRules class we can now implement lots of types with little
318// code. Thank goodness C++ compilers are great at stomping out layers of
319// templates... can you imagine having to do this all by hand? (/me is lazy :)
320//
Chris Lattner2f7c9632001-06-06 20:29:01 +0000321
322// ConstRules::find - Return the constant rules that take care of the specified
Chris Lattner61607ee2001-09-09 21:01:20 +0000323// type.
Chris Lattner2f7c9632001-06-06 20:29:01 +0000324//
Chris Lattner61607ee2001-09-09 21:01:20 +0000325Annotation *ConstRules::find(AnnotationID AID, const Annotable *TyA, void *) {
326 assert(AID == ConstRules::AID && "Bad annotation for factory!");
Chris Lattner8f191122001-10-01 18:26:53 +0000327 const Type *Ty = cast<Type>((const Value*)TyA);
Chris Lattner61607ee2001-09-09 21:01:20 +0000328
Chris Lattner2f7c9632001-06-06 20:29:01 +0000329 switch (Ty->getPrimitiveID()) {
Chris Lattner977f0042001-11-01 05:55:13 +0000330 case Type::BoolTyID: return new BoolRules();
331 case Type::PointerTyID: return new PointerRules();
Chris Lattner61607ee2001-09-09 21:01:20 +0000332 case Type::SByteTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000333 return new DirectRules<ConstantSInt, signed char , &Type::SByteTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000334 case Type::UByteTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000335 return new DirectRules<ConstantUInt, unsigned char , &Type::UByteTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000336 case Type::ShortTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000337 return new DirectRules<ConstantSInt, signed short, &Type::ShortTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000338 case Type::UShortTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000339 return new DirectRules<ConstantUInt, unsigned short, &Type::UShortTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000340 case Type::IntTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000341 return new DirectRules<ConstantSInt, signed int , &Type::IntTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000342 case Type::UIntTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000343 return new DirectRules<ConstantUInt, unsigned int , &Type::UIntTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000344 case Type::LongTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000345 return new DirectRules<ConstantSInt, int64_t , &Type::LongTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000346 case Type::ULongTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000347 return new DirectRules<ConstantUInt, uint64_t , &Type::ULongTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000348 case Type::FloatTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000349 return new DirectRules<ConstantFP , float , &Type::FloatTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000350 case Type::DoubleTyID:
Chris Lattner3462ae32001-12-03 22:26:30 +0000351 return new DirectRules<ConstantFP , double , &Type::DoubleTy>();
Chris Lattner61607ee2001-09-09 21:01:20 +0000352 default:
353 return new EmptyRules();
Chris Lattner2f7c9632001-06-06 20:29:01 +0000354 }
Chris Lattner2f7c9632001-06-06 20:29:01 +0000355}