Mercurial > hg > CbC > CbC_llvm
changeset 17:5e1f5bc27634
remove codeFlag for llvm type and add __CodeTy
line wrap: on
line diff
--- 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);
--- 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.
--- 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;
--- 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);
--- 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<IntegerType>(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<IntegerType>(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<uint8_t, 128> 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()) {
--- 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:
--- 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; } case Type::VoidTyID: +#ifndef noCbC + case Type::__CodeTyID: +#endif rv.IntVal = APInt(32, ((int(*)())(intptr_t)FPtr)()); return rv; case Type::FloatTyID:
--- a/lib/IR/AsmWriter.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/IR/AsmWriter.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -187,6 +187,9 @@ void TypePrinting::print(Type *Ty, raw_ostream &OS) { switch (Ty->getTypeID()) { case Type::VoidTyID: OS << "void"; break; +#ifndef noCbC + case Type::__CodeTyID: OS << "void"; break; +#endif case Type::HalfTyID: OS << "half"; break; case Type::FloatTyID: OS << "float"; break; case Type::DoubleTyID: OS << "double"; break;
--- a/lib/IR/Core.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/IR/Core.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -163,6 +163,9 @@ switch (unwrap(Ty)->getTypeID()) { default: llvm_unreachable("Unhandled TypeID."); case Type::VoidTyID: +#ifndef noCbC + case Type::__CodeTyID: +#endif return LLVMVoidTypeKind; case Type::HalfTyID: return LLVMHalfTypeKind;
--- a/lib/IR/LLVMContextImpl.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/IR/LLVMContextImpl.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -30,6 +30,9 @@ FP128Ty(C, Type::FP128TyID), PPC_FP128Ty(C, Type::PPC_FP128TyID), X86_MMXTy(C, Type::X86_MMXTyID), +#ifndef noCbC + __CodeTy(C, Type::__CodeTyID), +#endif Int1Ty(C, 1), Int8Ty(C, 8), Int16Ty(C, 16),
--- a/lib/IR/LLVMContextImpl.h Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/IR/LLVMContextImpl.h Sat Oct 05 22:04:18 2013 +0900 @@ -294,8 +294,11 @@ // Basic type instances. Type VoidTy, LabelTy, HalfTy, FloatTy, DoubleTy, MetadataTy; Type X86_FP80Ty, FP128Ty, PPC_FP128Ty, X86_MMXTy; +#ifndef noCbC + Type __CodeTy; +#endif IntegerType Int1Ty, Int8Ty, Int16Ty, Int32Ty, Int64Ty; - + /// TypeAllocator - All dynamically allocated types are allocated from this. /// They live forever until the context is torn down. BumpPtrAllocator TypeAllocator;
--- a/lib/IR/Type.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/IR/Type.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -35,6 +35,9 @@ case LabelTyID : return getLabelTy(C); case MetadataTyID : return getMetadataTy(C); case X86_MMXTyID : return getX86_MMXTy(C); +#ifndef noCbC + case __CodeTyID : return get__CodeTy(C); +#endif default: return 0; } @@ -234,6 +237,9 @@ Type *Type::getFP128Ty(LLVMContext &C) { return &C.pImpl->FP128Ty; } Type *Type::getPPC_FP128Ty(LLVMContext &C) { return &C.pImpl->PPC_FP128Ty; } Type *Type::getX86_MMXTy(LLVMContext &C) { return &C.pImpl->X86_MMXTy; } +#ifndef noCbC +Type *Type::get__CodeTy(LLVMContext &C) { return &C.pImpl->__CodeTy; } +#endif IntegerType *Type::getInt1Ty(LLVMContext &C) { return &C.pImpl->Int1Ty; } IntegerType *Type::getInt8Ty(LLVMContext &C) { return &C.pImpl->Int8Ty; }
--- a/lib/IR/ValueTypes.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/IR/ValueTypes.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -240,6 +240,9 @@ if (HandleUnknown) return MVT(MVT::Other); llvm_unreachable("Unknown type!"); case Type::VoidTyID: +#ifndef noCbC + case Type::__CodeTyID: +#endif return MVT::isVoid; case Type::IntegerTyID: return getIntegerVT(cast<IntegerType>(Ty)->getBitWidth());
--- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -318,7 +318,11 @@ bool isABI = (nvptxSubtarget.getSmVersion() >= 20); +#ifndef noCbC + if (Ty->getTypeID() == Type::VoidTyID || Ty->getTypeID() == Type::__CodeTyID) +#else if (Ty->getTypeID() == Type::VoidTyID) +#endif return; O << " (";
--- a/lib/Target/NVPTX/NVPTXISelLowering.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/Target/NVPTX/NVPTXISelLowering.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -290,7 +290,11 @@ std::stringstream O; O << "prototype_" << uniqueCallSite << " : .callprototype "; +#ifndef noCbC + if (retTy->getTypeID() == Type::VoidTyID || retTy->getTypeID() == Type::__CodeTyID) +#else if (retTy->getTypeID() == Type::VoidTyID) +#endif O << "()"; else { O << "(";
--- a/lib/Target/XCore/XCoreISelLowering.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/Target/XCore/XCoreISelLowering.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -1539,7 +1539,11 @@ bool XCoreTargetLowering::isLegalAddressingMode(const AddrMode &AM, Type *Ty) const { +#ifndef noCbC + if (Ty->getTypeID() == Type::VoidTyID || Ty->getTypeID() == Type::__CodeTyID) +#else if (Ty->getTypeID() == Type::VoidTyID) +#endif return AM.Scale == 0 && isImmUs(AM.BaseOffs) && isImmUs4(AM.BaseOffs); const DataLayout *TD = TM.getDataLayout();
--- a/lib/Transforms/IPO/MergeFunctions.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/Transforms/IPO/MergeFunctions.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -238,6 +238,9 @@ case Type::PPC_FP128TyID: case Type::LabelTyID: case Type::MetadataTyID: +#ifndef noCbC + case Type::__CodeTyID: +#endif return true; case Type::PointerTyID: {
--- a/lib/Transforms/IPO/PruneEH.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/lib/Transforms/IPO/PruneEH.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -107,10 +107,12 @@ } else if (CheckReturn && isa<ReturnInst>(BB->getTerminator())) { SCCMightReturn = true; } + /* #ifndef noCbC else if(F->getReturnType()->is__CodeTy()) SCCMightReturn = true; #endif + */ // Invoke instructions don't allow unwinding to continue, so we are // only interested in call instructions. if (CheckUnwind && !SCCMightUnwind)
--- a/tools/clang/include/clang/AST/Stmt.h Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/include/clang/AST/Stmt.h Sat Oct 05 22:04:18 2013 +0900 @@ -1325,9 +1325,6 @@ Stmt *RetExpr; SourceLocation RetLoc; const VarDecl *NRVOCandidate; -#ifndef noCbC - bool is__CodeFlag; -#endif public: ReturnStmt(SourceLocation RL) @@ -1370,16 +1367,6 @@ return child_range(); } - // accessor for __code flag. -#ifndef noCbC - void set__CodeFlag(bool f) { - is__CodeFlag = f; - } - - bool is__Code() { - return is__CodeFlag; - } -#endif }; /// AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
--- a/tools/clang/include/clang/AST/Type.h Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/include/clang/AST/Type.h Sat Oct 05 22:04:18 2013 +0900 @@ -1519,7 +1519,7 @@ bool isCompoundType() const; #ifndef noCbC - bool is__CodeType() const; // C99 6.2.5p19 + bool is__CodeType() const; // for CbC #endif // Type Predicates: Check to see if this type is structurally the specified
--- a/tools/clang/lib/AST/ItaniumMangle.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/lib/AST/ItaniumMangle.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -1862,6 +1862,9 @@ // ::= u <source-name> # vendor extended type switch (T->getKind()) { case BuiltinType::Void: Out << 'v'; break; +#ifndef noCbC + case BuiltinType::__Code: Out << 'v'; break; +#endif case BuiltinType::Bool: Out << 'b'; break; case BuiltinType::Char_U: case BuiltinType::Char_S: Out << 'c'; break; case BuiltinType::UChar: Out << 'h'; break;
--- a/tools/clang/lib/AST/MicrosoftMangle.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/lib/AST/MicrosoftMangle.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -1100,6 +1100,9 @@ // ::= _Z # __float80 (Digital Mars) switch (T->getKind()) { case BuiltinType::Void: Out << 'X'; break; +#ifndef noCbC + case BuiltinType::__Code: Out << 'X'; break; +#endif case BuiltinType::SChar: Out << 'C'; break; case BuiltinType::Char_U: case BuiltinType::Char_S: Out << 'D'; break; case BuiltinType::UChar: Out << 'E'; break;
--- a/tools/clang/lib/CodeGen/CGCall.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/lib/CodeGen/CGCall.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -891,10 +891,13 @@ } case ABIArgInfo::Ignore: - resultType = llvm::Type::getVoidTy(getLLVMContext()); #ifndef noCbC if (FI.getReturnType().getTypePtr()->is__CodeType()) - resultType->set__CodeFlag(true); + resultType = llvm::Type::get__CodeTy(getLLVMContext()); + else + resultType = llvm::Type::getVoidTy(getLLVMContext()); +#else + resultType = llvm::Type::getVoidTy(getLLVMContext()); #endif break; }
--- a/tools/clang/lib/CodeGen/CodeGenModule.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/lib/CodeGen/CodeGenModule.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -2104,7 +2104,6 @@ // Compute the function info and LLVM type. const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD); llvm::FunctionType *Ty = getTypes().GetFunctionType(FI); - // Get or create the prototype for the function. llvm::Constant *Entry = GetAddrOfFunction(GD, Ty);
--- a/tools/clang/lib/Parse/ParseExprCXX.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/lib/Parse/ParseExprCXX.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -1581,12 +1581,6 @@ case tok::kw_void: DS.SetTypeSpecType(DeclSpec::TST_void, Loc, PrevSpec, DiagID); break; -#ifndef noCbC - case tok::kw___code: - DS.SetTypeSpecType(DeclSpec::TST_void, Loc, PrevSpec, DiagID); - break; -#endif - case tok::kw_char: DS.SetTypeSpecType(DeclSpec::TST_char, Loc, PrevSpec, DiagID); break;
--- a/tools/clang/lib/Parse/ParseStmt.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/lib/Parse/ParseStmt.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -1660,7 +1660,7 @@ gotoRes = ParseExprStatement(); // don't need return because this code segment caller isn't code segment. - if (!Actions.getCurFunctionDecl()->getResultType().getTypePtr()->isVoidType()) + if (!Actions.getCurFunctionDecl()->getResultType().getTypePtr()->is__CodeType()) return gotoRes; }
--- a/tools/clang/lib/Sema/SemaStmt.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/lib/Sema/SemaStmt.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -2672,11 +2672,6 @@ } Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0); -#ifndef noCbC - if (FnRetType->is__CodeType()) - Result->set__CodeFlag(true); -#endif - } else if (!RetValExp && !HasDependentReturnType) { unsigned DiagID = diag::warn_return_missing_expr; // C90 6.6.6.4p4 // C99 6.8.6.4p1 (ext_ since GCC warns)
--- a/tools/clang/tools/libclang/CIndexUSRs.cpp Tue Sep 24 19:04:26 2013 +0900 +++ b/tools/clang/tools/libclang/CIndexUSRs.cpp Sat Oct 05 22:04:18 2013 +0900 @@ -538,6 +538,9 @@ unsigned char c = '\0'; switch (BT->getKind()) { case BuiltinType::Void: +#ifndef noCbC + case BuiltinType::__Code: +#endif c = 'v'; break; case BuiltinType::Bool: c = 'b'; break;