[llvm-commits] [dragonegg] r137210 - in /dragonegg/trunk: include/dragonegg/Types.h src/Constants.cpp src/Convert.cpp src/Types.cpp
Duncan Sands
baldrick at free.fr
Wed Aug 10 05:18:40 PDT 2011
Author: baldrick
Date: Wed Aug 10 07:18:39 2011
New Revision: 137210
URL: http://llvm.org/viewvc/llvm-project?rev=137210&view=rev
Log:
Get rid of isSequentialCompatible, replacing it with isSizeCompatible [the
relationship is: isSequentialCompatible(t) = isSizeCompatible(TREE_TYPE(t))].
Modified:
dragonegg/trunk/include/dragonegg/Types.h
dragonegg/trunk/src/Constants.cpp
dragonegg/trunk/src/Convert.cpp
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/include/dragonegg/Types.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Types.h?rev=137210&r1=137209&r2=137210&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Types.h (original)
+++ dragonegg/trunk/include/dragonegg/Types.h Wed Aug 10 07:18:39 2011
@@ -65,11 +65,10 @@
extern llvm::Type *GetUnitPointerType(llvm::LLVMContext &C,
unsigned AddrSpace = 0);
-/// isSequentialCompatible - Return true if the specified gcc array, pointer or
-/// vector type and the corresponding LLVM SequentialType lay out their elements
-/// identically in memory, so doing a GEP accesses the right memory location.
-/// We assume that objects without a known size do not.
-extern bool isSequentialCompatible(tree_node *type);
+/// isSizeCompatible - Return true if the specified gcc type is guaranteed to be
+/// turned by ConvertType into an LLVM type of the same size (i.e. TYPE_SIZE the
+/// same as getTypeAllocSizeInBits).
+extern bool isSizeCompatible(tree_node *type);
/// getRegType - Returns the LLVM type to use for registers that hold a value
/// of the scalar GCC type 'type'. All of the EmitReg* routines use this to
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=137210&r1=137209&r2=137210&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Wed Aug 10 07:18:39 2011
@@ -804,7 +804,7 @@
Type *EltTy = ConvertType(elt_type);
// Check that the element type has a known, constant size.
- assert(isSequentialCompatible(init_type) && "Variable sized array element!");
+ assert(isSizeCompatible(elt_type) && "Variable sized array element!");
uint64_t EltSize = TD.getTypeAllocSizeInBits(EltTy);
/// Elts - The initial values to use for the array elements. A null entry
@@ -1397,7 +1397,7 @@
assert(TREE_CODE(TREE_TYPE(array)) == ARRAY_TYPE && "Unknown ARRAY_REF!");
// Check for variable sized reference.
- assert(isSequentialCompatible(TREE_TYPE(array)) &&
+ assert(isSizeCompatible(TREE_TYPE(TREE_TYPE(array))) &&
"Global with variable size?");
// Get the index into the array as an LLVM integer constant.
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=137210&r1=137209&r2=137210&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed Aug 10 07:18:39 2011
@@ -1466,7 +1466,7 @@
// For array types, multiply the array length by the component cost.
if (TREE_CODE(type) == ARRAY_TYPE) {
// If this is an array with a funky component type then just give up.
- if (!isSequentialCompatible(type))
+ if (!isSizeCompatible(TREE_TYPE(type)))
return TooCostly;
uint64_t ArrayLength = ArrayLengthOf(type);
if (ArrayLength >= TooCostly)
@@ -5636,7 +5636,7 @@
/*isSigned*/!TYPE_UNSIGNED(IndexType));
// If we are indexing over a fixed-size type, just use a GEP.
- if (isSequentialCompatible(ArrayTreeType)) {
+ if (isSizeCompatible(ElementType)) {
// Avoid any assumptions about how the array type is represented in LLVM by
// doing the GEP on a pointer to the first array element.
Type *EltTy = ConvertType(ElementType);
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=137210&r1=137209&r2=137210&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Wed Aug 10 07:18:39 2011
@@ -285,21 +285,14 @@
return GetUnitType(C)->getPointerTo(AddrSpace);
}
-/// isSequentialCompatible - Return true if the specified gcc array, pointer or
-/// vector type and the corresponding LLVM SequentialType lay out their elements
-/// identically in memory, so doing a GEP accesses the right memory location.
-/// We assume that objects without a known size do not.
-bool isSequentialCompatible(tree type) {
- assert((TREE_CODE(type) == ARRAY_TYPE ||
- TREE_CODE(type) == POINTER_TYPE ||
- TREE_CODE(type) == VECTOR_TYPE ||
- TREE_CODE(type) == REFERENCE_TYPE) && "not a sequential type!");
- // This relies on gcc types with constant size mapping to LLVM types with the
- // same size. It is possible for the component type not to have a size:
- // struct foo; extern foo bar[];
- return isInt64(TYPE_SIZE(TREE_TYPE(type)), true);
+/// isSizeCompatible - Return true if the specified gcc type is guaranteed to be
+/// turned by ConvertType into an LLVM type of the same size (i.e. TYPE_SIZE the
+/// same as getTypeAllocSizeInBits).
+bool isSizeCompatible(tree type) {
+ return isInt64(TYPE_SIZE(type), true);
}
+
//===----------------------------------------------------------------------===//
// Matching LLVM types with GCC trees
//===----------------------------------------------------------------------===//
@@ -310,11 +303,11 @@
static Type *llvm_set_type(tree Tr, Type *Ty) {
assert(TYPE_P(Tr) && "Expected a gcc type!");
+#ifndef NDEBUG
// Check that the LLVM and GCC types have the same size, or, if the type has
// variable size, that the LLVM type is not bigger than any possible value of
// the GCC type.
-#ifndef NDEBUG
- if (Ty->isSized() && isInt64(TYPE_SIZE(Tr), true)) {
+ if (Ty->isSized() && isSizeCompatible(Tr)) {
uint64_t LLVMSize = getTargetData().getTypeAllocSizeInBits(Ty);
if (getInt64(TYPE_SIZE(Tr), true) != LLVMSize) {
errs() << "GCC: ";
More information about the llvm-commits
mailing list