[llvm-commits] [dragonegg] r134012 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp src/Types.cpp
Duncan Sands
baldrick at free.fr
Tue Jun 28 10:21:53 PDT 2011
Author: baldrick
Date: Tue Jun 28 12:21:53 2011
New Revision: 134012
URL: http://llvm.org/viewvc/llvm-project?rev=134012&view=rev
Log:
Handle void* correctly in the MEM_REF and TARGET_MEM_REF support code.
Modified:
dragonegg/trunk/include/dragonegg/Internals.h
dragonegg/trunk/src/Convert.cpp
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=134012&r1=134011&r2=134012&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Tue Jun 28 12:21:53 2011
@@ -242,6 +242,10 @@
return TheTypeConverter->ConvertType(type);
}
+/// getPointerToType - Returns the LLVM register type to use for a pointer to
+/// the given GCC type.
+const Type *getPointerToType(tree_node *type);
+
/// getDefaultValue - Return the default value to use for a constant or global
/// that has no value specified. For example in C like languages such variables
/// are initialized to zero, while in Ada they hold an undefined value.
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=134012&r1=134011&r2=134012&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Tue Jun 28 12:21:53 2011
@@ -5960,8 +5960,7 @@
}
// Ensure the pointer has the right type.
- Addr = Builder.CreateBitCast(Addr,
- ConvertType(TREE_TYPE(exp))->getPointerTo());
+ Addr = Builder.CreateBitCast(Addr, getPointerToType(TREE_TYPE(exp)));
unsigned Alignment = std::max(TYPE_ALIGN(TREE_TYPE (exp)),
get_object_alignment(exp, BIGGEST_ALIGNMENT));
bool Volatile = TREE_THIS_VOLATILE(exp);
@@ -6070,8 +6069,7 @@
}
// The result can be of a different pointer type even if we didn't advance it.
- Addr = Builder.CreateBitCast(Addr,
- ConvertType(TREE_TYPE(exp))->getPointerTo());
+ Addr = Builder.CreateBitCast(Addr, getPointerToType(TREE_TYPE(exp)));
unsigned Alignment = TYPE_ALIGN(TREE_TYPE (exp));
#if (GCC_MINOR < 6)
Alignment = get_object_alignment(exp, Alignment, BIGGEST_ALIGNMENT);
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=134012&r1=134011&r2=134012&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Tue Jun 28 12:21:53 2011
@@ -550,6 +550,15 @@
}
}
+/// getPointerToType - Returns the LLVM register type to use for a pointer to
+/// the given GCC type.
+const Type *getPointerToType(tree type) {
+ if (VOID_TYPE_P(type))
+ // void* -> byte*
+ return GetUnitPointerType(Context);
+ // FIXME: Handle address spaces.
+ return ConvertType(type)->getPointerTo();
+}
const Type *TypeConverter::ConvertType(tree type) {
if (type == error_mark_node) return Type::getInt32Ty(Context);
More information about the llvm-commits
mailing list