[llvm-commits] [dragonegg] r163474 - in /dragonegg/trunk: include/dragonegg/Trees.h src/Convert.cpp src/TypeConversion.cpp

Duncan Sands baldrick at free.fr
Sat Sep 8 11:22:56 PDT 2012


Author: baldrick
Date: Sat Sep  8 13:22:56 2012
New Revision: 163474

URL: http://llvm.org/viewvc/llvm-project?rev=163474&view=rev
Log:
Enforce some invariants required by dragonegg at compile time.

Modified:
    dragonegg/trunk/include/dragonegg/Trees.h
    dragonegg/trunk/src/Convert.cpp
    dragonegg/trunk/src/TypeConversion.cpp

Modified: dragonegg/trunk/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Trees.h?rev=163474&r1=163473&r2=163474&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Trees.h (original)
+++ dragonegg/trunk/include/dragonegg/Trees.h Sat Sep  8 13:22:56 2012
@@ -36,6 +36,15 @@
 // headers (and this one, as it may include GCC headers) are always included
 // last.
 
+// The following properties must hold if dragonegg is to work correctly.
+#if ((BITS_PER_UNIT & 7) != 0)
+#error	BITS_PER_UNIT must be a multiple of 8
+#endif
+#if ((BITS_PER_UNIT & (BITS_PER_UNIT - 1)) != 0)
+#error	BITS_PER_UNIT must be a power of 2
+#endif
+
+
 /// dragonegg_tree_code - Fake helper tree codes.
 enum dragonegg_tree_code {
   ACCESS_TYPE,          // A pointer or reference type.

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=163474&r1=163473&r2=163474&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Sat Sep  8 13:22:56 2012
@@ -6085,7 +6085,6 @@
     // Offset will hold the field offset in octets.
     Value *Offset;
 
-    assert(!(BITS_PER_UNIT & 7) && "Unit size not a multiple of 8 bits!");
     if (TREE_OPERAND(exp, 2)) {
       Offset = EmitRegister(TREE_OPERAND(exp, 2));
       // At this point the offset is measured in units divided by (exactly)

Modified: dragonegg/trunk/src/TypeConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/TypeConversion.cpp?rev=163474&r1=163473&r2=163474&view=diff
==============================================================================
--- dragonegg/trunk/src/TypeConversion.cpp (original)
+++ dragonegg/trunk/src/TypeConversion.cpp Sat Sep  8 13:22:56 2012
@@ -308,9 +308,6 @@
 /// example, on a machine which has 16 bit bytes returns an i16 or an array of
 /// i16.
 Type *GetUnitType(LLVMContext &C, unsigned NumUnits) {
-  // The following assertion is here because just about every place that calls
-  // this routine implicitly assumes this.
-  assert(!(BITS_PER_UNIT & 7) && "Unit size not a multiple of 8 bits!");
   Type *UnitTy = IntegerType::get(C, BITS_PER_UNIT);
   if (NumUnits == 1)
     return UnitTy;





More information about the llvm-commits mailing list