diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-13 04:09:18 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-13 04:09:18 +0000 |
commit | 0a5372ed3e8cda10d724feda3c1a1c998db05ca0 (patch) | |
tree | 89dc39f73d938c223b4e192bc6fd918490a60218 /include/llvm | |
parent | f1db120d0494ec55d9265cea7dab22e80dcae10c (diff) | |
download | external_llvm-0a5372ed3e8cda10d724feda3c1a1c998db05ca0.tar.gz external_llvm-0a5372ed3e8cda10d724feda3c1a1c998db05ca0.tar.bz2 external_llvm-0a5372ed3e8cda10d724feda3c1a1c998db05ca0.zip |
Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
This involves temporarily hard wiring some parts to use the global context. This isn't ideal, but it's
the only way I could figure out to make this process vaguely incremental.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/CodeGen/FastISel.h | 1 | ||||
-rw-r--r-- | include/llvm/Constant.h | 8 | ||||
-rw-r--r-- | include/llvm/Constants.h | 23 | ||||
-rw-r--r-- | include/llvm/InstrTypes.h | 16 | ||||
-rw-r--r-- | include/llvm/LLVMContext.h | 14 | ||||
-rw-r--r-- | include/llvm/Support/IRBuilder.h | 4 |
6 files changed, 31 insertions, 35 deletions
diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h index c7b1a42d06..857267c011 100644 --- a/include/llvm/CodeGen/FastISel.h +++ b/include/llvm/CodeGen/FastISel.h @@ -60,6 +60,7 @@ protected: const TargetData &TD; const TargetInstrInfo &TII; const TargetLowering &TLI; + LLVMContext *Context; public: /// startNewBlock - Set the current block to which generated machine diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h index d4949d1a0f..05a6623200 100644 --- a/include/llvm/Constant.h +++ b/include/llvm/Constant.h @@ -18,6 +18,7 @@ namespace llvm { template<typename T> class SmallVectorImpl; + class LLVMContext; /// If object contains references to other objects, then relocations are /// usually required for emission of such object (especially in PIC mode). One @@ -59,10 +60,6 @@ protected: void destroyConstantImpl(); public: - /// Static constructor to get a '0' constant of arbitrary type... - /// - static Constant *getNullValue(const Type *Ty); - /// Static constructor to get a '-1' constant. This supports integers and /// vectors. /// @@ -98,7 +95,8 @@ public: /// type, returns the elements of the vector in the specified smallvector. /// This handles breaking down a vector undef into undef elements, etc. For /// constant exprs and other cases we can't handle, we return an empty vector. - void getVectorElements(SmallVectorImpl<Constant*> &Elts) const; + void getVectorElements(LLVMContext &Context, + SmallVectorImpl<Constant*> &Elts) const; /// destroyConstant - Called if some element of this constant is no longer /// valid. At this point only other constants may be on the use_list for this diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 09750668a1..77124d8974 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -276,9 +276,6 @@ public: /// considers -0.0 to be null as well as 0.0. :( virtual bool isNullValue() const; - // Get a negative zero. - static ConstantFP *getNegativeZero(const Type* Ty); - /// isExactlyValue - We don't rely on operator== working on double values, as /// it returns true for things that are clearly not equal, like -0.0 and 0.0. /// As such, this method can be used to do an exact bit-for-bit comparison of @@ -383,7 +380,7 @@ public: /// isString) and it ends in a null byte \0 and does not contains any other /// @endverbatim /// null bytes except its terminator. - bool isCString() const; + bool isCString(LLVMContext &Context) const; /// getAsString - If this array is isString(), then this method converts the /// array to an std::string and returns it. Otherwise, it asserts out. @@ -694,17 +691,6 @@ public: return getSelectTy(V1->getType(), C, V1, V2); } - /// getAlignOf constant expr - computes the alignment of a type in a target - /// independent way (Note: the return type is an i32; Note: assumes that i8 - /// is byte aligned). - /// - static Constant *getAlignOf(const Type *Ty); - - /// getSizeOf constant expr - computes the size of a type in a target - /// independent way (Note: the return type is an i64). - /// - static Constant *getSizeOf(const Type *Ty); - /// ConstantExpr::get - Return a binary or shift operator constant expression, /// folding if possible. /// @@ -716,8 +702,6 @@ public: /// ConstantExpr::get* - Return some common constants without having to /// specify the full Instruction::OPCODE identifier. /// - static Constant *getNeg(Constant *C); - static Constant *getFNeg(Constant *C); static Constant *getNot(Constant *C); static Constant *getAdd(Constant *C1, Constant *C2); static Constant *getFAdd(Constant *C1, Constant *C2); @@ -756,11 +740,6 @@ public: static Constant *getInsertValue(Constant *Agg, Constant *Val, const unsigned *IdxList, unsigned NumIdx); - /// Floating point negation must be implemented with f(x) = -0.0 - x. This - /// method returns the negative zero constant for floating point or vector - /// floating point types; for all other types, it returns the null value. - static Constant *getZeroValueForNegationExpr(const Type *Ty); - /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return false; } diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 76827191f1..9c1f8fc804 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -202,13 +202,17 @@ public: /// CreateNeg, CreateNot - Create the NEG and NOT /// instructions out of SUB and XOR instructions. /// - static BinaryOperator *CreateNeg(Value *Op, const std::string &Name = "", + static BinaryOperator *CreateNeg(LLVMContext &Context, + Value *Op, const std::string &Name = "", Instruction *InsertBefore = 0); - static BinaryOperator *CreateNeg(Value *Op, const std::string &Name, + static BinaryOperator *CreateNeg(LLVMContext &Context, + Value *Op, const std::string &Name, BasicBlock *InsertAtEnd); - static BinaryOperator *CreateFNeg(Value *Op, const std::string &Name = "", + static BinaryOperator *CreateFNeg(LLVMContext &Context, + Value *Op, const std::string &Name = "", Instruction *InsertBefore = 0); - static BinaryOperator *CreateFNeg(Value *Op, const std::string &Name, + static BinaryOperator *CreateFNeg(LLVMContext &Context, + Value *Op, const std::string &Name, BasicBlock *InsertAtEnd); static BinaryOperator *CreateNot(Value *Op, const std::string &Name = "", Instruction *InsertBefore = 0); @@ -218,8 +222,8 @@ public: /// isNeg, isFNeg, isNot - Check if the given Value is a /// NEG, FNeg, or NOT instruction. /// - static bool isNeg(const Value *V); - static bool isFNeg(const Value *V); + static bool isNeg(LLVMContext &Context, const Value *V); + static bool isFNeg(LLVMContext &Context, const Value *V); static bool isNot(const Value *V); /// getNegArgument, getNotArgument - Helper functions to extract the diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 75b7e59ceb..e441d189c2 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -120,6 +120,11 @@ public: bool isSigned); Constant* getConstantExprFPCast(Constant* C, const Type* Ty); Constant* getConstantExprSelect(Constant* C, Constant* V1, Constant* V2); + + /// getAlignOf constant expr - computes the alignment of a type in a target + /// independent way (Note: the return type is an i32; Note: assumes that i8 + /// is byte aligned). + /// Constant* getConstantExprAlignOf(const Type* Ty); Constant* getConstantExprCompare(unsigned short pred, Constant* C1, Constant* C2); @@ -162,7 +167,15 @@ public: Constant* getConstantExprInsertValue(Constant* Agg, Constant* Val, const unsigned* IdxList, unsigned NumIdx); + + /// getSizeOf constant expr - computes the size of a type in a target + /// independent way (Note: the return type is an i64). + /// Constant* getConstantExprSizeOf(const Type* Ty); + + /// Floating point negation must be implemented with f(x) = -0.0 - x. This + /// method returns the negative zero constant for floating point or vector + /// floating point types; for all other types, it returns the null value. Constant* getZeroValueForNegation(const Type* Ty); // ConstantFP accessors @@ -200,6 +213,7 @@ public: StructType* getStructType(bool isPacked=false); StructType* getStructType(const std::vector<const Type*>& Params, bool isPacked = false); + StructType* getStructType(const Type* type, ...); // ArrayType accessors ArrayType* getArrayType(const Type* ElementType, uint64_t NumElements); diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 9fc29ef44e..5de33eb2cb 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -311,12 +311,12 @@ public: Value *CreateNeg(Value *V, const char *Name = "") { if (Constant *VC = dyn_cast<Constant>(V)) return Folder.CreateNeg(VC); - return Insert(BinaryOperator::CreateNeg(V), Name); + return Insert(BinaryOperator::CreateNeg(getGlobalContext(), V), Name); } Value *CreateFNeg(Value *V, const char *Name = "") { if (Constant *VC = dyn_cast<Constant>(V)) return Folder.CreateFNeg(VC); - return Insert(BinaryOperator::CreateFNeg(V), Name); + return Insert(BinaryOperator::CreateFNeg(getGlobalContext(), V), Name); } Value *CreateNot(Value *V, const char *Name = "") { if (Constant *VC = dyn_cast<Constant>(V)) |