# HG changeset patch # User Kaito Tokumori # Date 1380978258 -32400 # Node ID 5e1f5bc2763498b0b45c7386d85014467decfecd # Parent d405342cecb18e777860fdb6476367769d5f9267 remove codeFlag for llvm type and add __CodeTy diff -r d405342cecb1 -r 5e1f5bc27634 include/llvm/IR/IRBuilder.h --- a/include/llvm/IR/IRBuilder.h Tue Sep 24 19:04:26 2013 +0900 +++ b/include/llvm/IR/IRBuilder.h Sat Oct 05 22:04:18 2013 +0900 @@ -284,6 +284,12 @@ return Type::getVoidTy(Context); } +#ifndef noCbC + Type *get__CodeTy() { + return Type::get__CodeTy(Context); + } +#endif + /// \brief Fetch the type representing a pointer to an 8-bit integer value. PointerType *getInt8PtrTy(unsigned AddrSpace = 0) { return Type::getInt8PtrTy(Context, AddrSpace); diff -r d405342cecb1 -r 5e1f5bc27634 include/llvm/IR/Type.h --- a/include/llvm/IR/Type.h Tue Sep 24 19:04:26 2013 +0900 +++ b/include/llvm/IR/Type.h Sat Oct 05 22:04:18 2013 +0900 @@ -72,6 +72,9 @@ PointerTyID, ///< 14: Pointers VectorTyID, ///< 15: SIMD 'packed' format, or other vector type +#ifndef noCbC + __CodeTyID, +#endif NumTypeIDs, // Must remain as last defined ID LastPrimitiveTyID = X86_MMXTyID, @@ -88,18 +91,11 @@ // Note: TypeID : low 8 bit; SubclassData : high 24 bit. uint32_t IDAndSubclassData; -#ifndef noCbC - bool is__Code; -#endif - protected: friend class LLVMContextImpl; explicit Type(LLVMContext &C, TypeID tid) : Context(C), IDAndSubclassData(0), NumContainedTys(0), ContainedTys(0) { -#ifndef noCbC - is__Code = false; -#endif setTypeID(tid); } ~Type() {} @@ -145,13 +141,15 @@ TypeID getTypeID() const { return (TypeID)(IDAndSubclassData & 0xFF); } /// isVoidTy - Return true if this is 'void'. +#ifndef noCbC + bool isVoidTy() const { return (getTypeID() == VoidTyID || getTypeID() == __CodeTyID); } +#else bool isVoidTy() const { return getTypeID() == VoidTyID; } +#endif #ifndef noCbC - void set__CodeFlag(bool f) { is__Code = f;} - /// is__CodeTy - Return true if this is '__code'. - bool is__CodeTy() const { return is__Code; } + bool is__CodeTy() const { return getTypeID() == __CodeTyID; } #endif /// isHalfTy - Return true if this is 'half', a 16-bit IEEE fp type. @@ -264,7 +262,11 @@ /// is a valid type for a Value. /// bool isFirstClassType() const { +#ifndef noCbC + return getTypeID() != FunctionTyID && getTypeID() != VoidTyID && getTypeID() != __CodeTyID; +#else return getTypeID() != FunctionTyID && getTypeID() != VoidTyID; +#endif } /// isSingleValueType - Return true if the type is a valid type for a @@ -272,9 +274,15 @@ /// and array types. /// bool isSingleValueType() const { +#ifndef noCbC + return (getTypeID() != VoidTyID && isPrimitiveType() && getTypeID() != __CodeTyID) || + getTypeID() == IntegerTyID || getTypeID() == PointerTyID || + getTypeID() == VectorTyID; +#else return (getTypeID() != VoidTyID && isPrimitiveType()) || getTypeID() == IntegerTyID || getTypeID() == PointerTyID || getTypeID() == VectorTyID; +#endif } /// isAggregateType - Return true if the type is an aggregate type. This @@ -410,6 +418,10 @@ static IntegerType *getInt32Ty(LLVMContext &C); static IntegerType *getInt64Ty(LLVMContext &C); +#ifndef noCbC + static Type *get__CodeTy(LLVMContext &C); // for CbC project +#endif + //===--------------------------------------------------------------------===// // Convenience methods for getting pointer types with one of the above builtin // types as pointee. diff -r d405342cecb1 -r 5e1f5bc27634 lib/Bitcode/Writer/BitcodeWriter.cpp --- a/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -301,6 +301,9 @@ switch (T->getTypeID()) { default: llvm_unreachable("Unknown type!"); case Type::VoidTyID: Code = bitc::TYPE_CODE_VOID; break; +#ifndef noCbC + case Type::__CodeTyID: Code = bitc::TYPE_CODE_VOID; break; +#endif case Type::HalfTyID: Code = bitc::TYPE_CODE_HALF; break; case Type::FloatTyID: Code = bitc::TYPE_CODE_FLOAT; break; case Type::DoubleTyID: Code = bitc::TYPE_CODE_DOUBLE; break; diff -r d405342cecb1 -r 5e1f5bc27634 lib/ExecutionEngine/Interpreter/Execution.cpp --- a/lib/ExecutionEngine/Interpreter/Execution.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -1616,6 +1616,9 @@ switch (I.getType()->getTypeID()) { default: llvm_unreachable("Invalid GenericValue Type"); case Type::VoidTyID: dbgs() << "void"; break; +#ifndef noCbC + case Type::__CodeTyID: dbgs() << "void"; break; +#endif case Type::FloatTyID: dbgs() << "float " << Val.FloatVal; break; case Type::DoubleTyID: dbgs() << "double " << Val.DoubleVal; break; case Type::PointerTyID: dbgs() << "void* " << intptr_t(Val.PointerVal); diff -r d405342cecb1 -r 5e1f5bc27634 lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -63,6 +63,9 @@ static char getTypeID(Type *Ty) { switch (Ty->getTypeID()) { case Type::VoidTyID: return 'V'; +#ifndef noCbC + case Type::__CodeTyID: return 'V'; +#endif case Type::IntegerTyID: switch (cast(Ty)->getBitWidth()) { case 1: return 'o'; @@ -113,6 +116,9 @@ static ffi_type *ffiTypeFor(Type *Ty) { switch (Ty->getTypeID()) { case Type::VoidTyID: return &ffi_type_void; +#ifndef noCbC + case Type::__CodeTyID: return &ffi_type_void; +#endif case Type::IntegerTyID: switch (cast(Ty)->getBitWidth()) { case 8: return &ffi_type_sint8; @@ -220,7 +226,11 @@ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NumArgs, rtype, &args[0]) == FFI_OK) { SmallVector ret; +#ifndef noCbC + if (RetTy->getTypeID() != Type::VoidTyID && RetTy->getTypeID() != Type::__CodeTyID) +#else if (RetTy->getTypeID() != Type::VoidTyID) +#endif ret.resize(TD->getTypeStoreSize(RetTy)); ffi_call(&cif, Fn, ret.data(), values.data()); switch (RetTy->getTypeID()) { diff -r d405342cecb1 -r 5e1f5bc27634 lib/ExecutionEngine/JIT/JIT.cpp --- a/lib/ExecutionEngine/JIT/JIT.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/ExecutionEngine/JIT/JIT.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -471,6 +471,9 @@ return rv; } case Type::VoidTyID: +#ifndef noCbC + case Type::__CodeTyID: +#endif rv.IntVal = APInt(32, ((int(*)())(intptr_t)FPtr)()); return rv; case Type::FloatTyID: diff -r d405342cecb1 -r 5e1f5bc27634 lib/ExecutionEngine/MCJIT/MCJIT.cpp --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -302,6 +302,9 @@ return rv;