[llvm-commits] [dragonegg] r166672 - in /dragonegg/trunk/src: ConstantConversion.cpp Convert.cpp TypeConversion.cpp
Villmow, Micah
Micah.Villmow at amd.com
Thu Oct 25 08:27:20 PDT 2012
Thanks for cleaning this up Duncan.
Should I update getIntPtrType or is that the work that Hal has been doing?
Micah
> -----Original Message-----
> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> bounces at cs.uiuc.edu] On Behalf Of Duncan Sands
> Sent: Thursday, October 25, 2012 2:13 AM
> To: llvm-commits at cs.uiuc.edu
> Subject: [llvm-commits] [dragonegg] r166672 - in /dragonegg/trunk/src:
> ConstantConversion.cpp Convert.cpp TypeConversion.cpp
>
> Author: baldrick
> Date: Thu Oct 25 04:12:37 2012
> New Revision: 166672
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166672&view=rev
> Log:
> Clean up after Micah's address space changes. Note that this assumes
> that getIntPtrType will be fixed to return a vector of integers when
> passed a vector of pointers.
>
> Modified:
> dragonegg/trunk/src/ConstantConversion.cpp
> dragonegg/trunk/src/Convert.cpp
> dragonegg/trunk/src/TypeConversion.cpp
>
> Modified: dragonegg/trunk/src/ConstantConversion.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/dragonegg/trunk/src/ConstantConversion.cpp?rev=166672&r1=166671&
> r2=166672&view=diff
> ========================================================================
> ======
> --- dragonegg/trunk/src/ConstantConversion.cpp (original)
> +++ dragonegg/trunk/src/ConstantConversion.cpp Thu Oct 25 04:12:37 2012
> @@ -559,16 +559,16 @@
> unsigned NumElts = TYPE_VECTOR_SUBPARTS(type);
> unsigned Stride = GET_MODE_BITSIZE(TYPE_MODE(elt_type));
> SmallVector<Constant*, 16> Vals(NumElts);
> - // FIXME: what is the address space here?
> - unsigned AS = 0;
> - IntegerType *IntPtrTy = getDataLayout().getIntPtrType(Context, AS);
> for (unsigned i = 0; i != NumElts; ++i) {
> Vals[i] = ExtractRegisterFromConstantImpl(C, elt_type,
> StartingBit+i*Stride,
> Folder);
> // LLVM does not support vectors of pointers, so turn any
> pointers into
> // integers.
> - if (isa<PointerType>(Vals[i]->getType()))
> + if (isa<PointerType>(Vals[i]->getType())) {
> + IntegerType *IntPtrTy =
> + getDataLayout().getIntPtrType(Vals[i]->getType());
> Vals[i] = Folder.CreatePtrToInt(Vals[i], IntPtrTy);
> + }
> }
> return ConstantVector::get(Vals);
> }
>
> Modified: dragonegg/trunk/src/Convert.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/dragonegg/trunk/src/Convert.cpp?rev=166672&r1=166671&r2=166672&v
> iew=diff
> ========================================================================
> ======
> --- dragonegg/trunk/src/Convert.cpp (original)
> +++ dragonegg/trunk/src/Convert.cpp Thu Oct 25 04:12:37 2012
> @@ -840,10 +840,8 @@
> // bytes, but only 10 are copied. If the object is really a
> union
> // we might need the other bytes. We must also be careful to
> use
> // the smaller alignment.
> - // FIXME: Where do we get the address space?
> - unsigned AS = 0;
> Type *SBP = Type::getInt8PtrTy(Context);
> - Type *IntPtr = getDataLayout().getIntPtrType(Context, AS);
> + Type *IntPtr = getDataLayout().getIntPtrType(Context, 0);
> Value *Ops[5] = {
> Builder.CreateCast(Instruction::BitCast, Loc, SBP),
> Builder.CreateCast(Instruction::BitCast, AI, SBP), @@ -1357,7
> +1355,7 @@
> Builder.CreateBitCast(ResultLV.Ptr,
> Type::getInt8PtrTy(Context));
> ResultLV.Ptr =
> Builder.CreateGEP(ResultLV.Ptr,
> -
> ConstantInt::get(TD.getIntPtrType(ResultLV.Ptr->getType()),
> +
> + ConstantInt::get(TD.getIntPtrType(Context, 0),
> ReturnOffset),
> flag_verbose_asm ? "rtvl" : "");
> ResultLV.setAlignment(MinAlign(ResultLV.getAlignment(),
> ReturnOffset)); @@ -1859,16 +1857,15 @@
> if (OrigEltTy->isIntegerTy())
> // Already an integer/vector of integer - nothing to do.
> return V;
> - unsigned VecElts = isa<VectorType>(OrigTy) ?
> - cast<VectorType>(OrigTy)->getNumElements() : 0;
> if (OrigEltTy->isPointerTy()) {
> // A pointer/vector of pointer - form a (vector of) pointer sized
> integers.
> - Type *NewEltTy = TD.getIntPtrType(OrigEltTy);
> - Type *NewTy = VecElts ? VectorType::get(NewEltTy, VecElts) :
> NewEltTy;
> + Type *NewTy = TD.getIntPtrType(OrigTy);
> return Builder.CreatePtrToInt(V, NewTy);
> }
> // Everything else.
> assert(OrigTy->isFPOrFPVectorTy() && "Expected a floating point
> type!");
> + unsigned VecElts = isa<VectorType>(OrigTy) ?
> + cast<VectorType>(OrigTy)->getNumElements() : 0;
> unsigned BitWidth = OrigEltTy->getPrimitiveSizeInBits();
> Type *NewEltTy = IntegerType::get(Context, BitWidth);
> Type *NewTy = VecElts ? VectorType::get(NewEltTy, VecElts) :
> NewEltTy; @@ -3480,8 +3477,9 @@
> if (Client.Offset) {
> Ptr = Builder.CreateBitCast(Ptr, Type::getInt8PtrTy(Context));
> Ptr = Builder.CreateGEP(Ptr,
> - ConstantInt::get(TD.getIntPtrType(Ptr->getType()),
> Client.Offset),
> - flag_verbose_asm ? "ro" : "");
> + ConstantInt::get(TD.getIntPtrType(Ptr-
> >getType()),
> + Client.Offset),
> + flag_verbose_asm ? "ro" : "");
> Align = MinAlign(Align, Client.Offset);
> MaxStoreSize -= Client.Offset;
> }
> @@ -5677,9 +5675,7 @@
> if (!validate_gimple_arglist(stmt, INTEGER_TYPE, POINTER_TYPE,
> VOID_TYPE))
> return false;
>
> - // FIXME: Where do I get the address space from here?
> - unsigned AS = 0;
> - Type *IntPtr = TD.getIntPtrType(Context, AS);
> + Type *IntPtr = TD.getIntPtrType(Context, 0);
> Value *Offset = EmitMemory(gimple_call_arg(stmt, 0));
> Value *Handler = EmitMemory(gimple_call_arg(stmt, 1));
>
> @@ -6604,15 +6600,14 @@
>
> // Convert the elements.
> SmallVector<Constant*, 16> Elts;
> - // FIXME: Where do I get the address space from?
> - unsigned AS = 0;
> - IntegerType *IntTy = getDataLayout().getIntPtrType(Context, AS);
> for (tree elt = TREE_VECTOR_CST_ELTS(reg); elt; elt =
> TREE_CHAIN(elt)) {
> Constant *Elt = EmitRegisterConstant(TREE_VALUE(elt));
> // LLVM does not support vectors of pointers, so turn any pointers
> into
> // integers.
> - if (isa<PointerType>(Elt->getType()))
> + if (isa<PointerType>(Elt->getType())) {
> + IntegerType *IntTy =
> + getDataLayout().getIntPtrType(Elt->getType());
> Elt = Builder.getFolder().CreatePtrToInt(Elt, IntTy);
> + }
> Elts.push_back(Elt);
> }
>
>
> Modified: dragonegg/trunk/src/TypeConversion.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/dragonegg/trunk/src/TypeConversion.cpp?rev=166672&r1=166671&r2=1
> 66672&view=diff
> ========================================================================
> ======
> --- dragonegg/trunk/src/TypeConversion.cpp (original)
> +++ dragonegg/trunk/src/TypeConversion.cpp Thu Oct 25 04:12:37 2012
> @@ -456,11 +456,9 @@
> return StructType::get(EltTy, EltTy, NULL);
> }
>
> - case OFFSET_TYPE: {
> - // FIXME: Need to get the Address space here.
> - unsigned AS = 0;
> - return getDataLayout().getIntPtrType(Context, AS);
> - }
> + case OFFSET_TYPE:
> + return getDataLayout().getIntPtrType(Context,
> + TYPE_ADDR_SPACE(type));
> +
> case POINTER_TYPE:
> case REFERENCE_TYPE:
> // void* -> byte*
> @@ -487,10 +485,10 @@
> case VECTOR_TYPE: {
> // LLVM does not support vectors of pointers, so turn any pointers
> into
> // integers. <-- This isn't true since at least 3.1 as far as I
> know - MicahV
> - // FIXME: Need to get the Address space here.
> - unsigned AS = 0;
> + // FIXME ^-- Yes, but does it work reliably? - Duncan
> Type *EltTy = isa<ACCESS_TYPE>(TREE_TYPE(type)) ?
> - getDataLayout().getIntPtrType(Context, AS) :
> getRegType(TREE_TYPE(type));
> + getDataLayout().getIntPtrType(Context,
> TYPE_ADDR_SPACE(TREE_TYPE(type))) :
> + getRegType(TREE_TYPE(type));
> return VectorType::get(EltTy, TYPE_VECTOR_SUBPARTS(type));
> }
>
> @@ -1423,8 +1421,7 @@
> // which are really just integer offsets. Return the appropriate
> integer
> // type directly.
> // Caching the type conversion is not worth it.
> - // FIXME: Need to get the Address space here.
> - unsigned AS = 0;
> + unsigned AS = TYPE_ADDR_SPACE(type);
> return CheckTypeConversion(type,
> getDataLayout().getIntPtrType(Context, AS));
> }
> case REAL_TYPE:
> @@ -1463,13 +1460,11 @@
> Type *Ty;
> // LLVM does not support vectors of pointers, so turn any pointers
> into
> // integers.
> - if (isa<ACCESS_TYPE>(TREE_TYPE(type))) {
> - // FIXME: Need to get the Address space here.
> - unsigned AS = 0;
> - Ty = getDataLayout().getIntPtrType(Context, AS);
> - } else {
> + if (isa<ACCESS_TYPE>(TREE_TYPE(type)))
> + Ty = getDataLayout().getIntPtrType(Context,
> +
> TYPE_ADDR_SPACE(TREE_TYPE(type)));
> + else
> Ty = ConvertTypeNonRecursive(main_type(type));
> - }
> Ty = VectorType::get(Ty, TYPE_VECTOR_SUBPARTS(type));
> return RememberTypeConversion(type, Ty);
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list