[llvm-commits] [hlvm] r38371 - /hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp

Reid Spencer reid at x10sys.com
Sat Jul 7 17:02:46 PDT 2007


Author: reid
Date: Sat Jul  7 19:02:45 2007
New Revision: 38371

URL: http://llvm.org/viewvc/llvm-project?rev=38371&view=rev
Log:
Support Range and Enum types.

Modified:
    hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp

Modified: hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp?rev=38371&r1=38370&r2=38371&view=diff

==============================================================================
--- hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp (original)
+++ hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp Sat Jul  7 19:02:45 2007
@@ -468,13 +468,16 @@
   // Okay, we haven't seen this type before so let's construct it
   switch (ty->getID()) {
     case BooleanTypeID:            result = llvm::Type::BoolTy; break;
-    case CharacterTypeID:          result = llvm::Type::UShortTy; break;
+    case CharacterTypeID:          result = llvm::Type::IntTy; break;
     case AnyTypeID:
       hlvmNotImplemented("Any Type");
       break;
     case StringTypeID:              
       result = llvm::PointerType::get(llvm::Type::SByteTy);
       break;
+    case EnumerationTypeID:
+      result = llvm::Type::UIntTy;
+      break;
     case IntegerTypeID:
     {
       const IntegerType* IT = llvm::cast<hlvm::IntegerType>(ty);
@@ -493,6 +496,28 @@
         hlvmNotImplemented("arbitrary precision integer");
       break;
     }
+    case RangeTypeID:
+    {
+      const RangeType* RT = llvm::cast<hlvm::RangeType>(ty);
+      if (RT->getMin() < 0) {
+        if (RT->getMin() >= SHRT_MIN && RT->getMax() <= SHRT_MAX)
+          return llvm::Type::ShortTy;
+        else if (RT->getMin() >= INT_MIN && RT->getMax() <= INT_MAX)
+          return llvm::Type::IntTy;
+        else
+          return llvm::Type::LongTy;
+      } else {
+        if (RT->getMax() <= USHRT_MAX)
+          return llvm::Type::UShortTy;
+        else if (RT->getMax() <= UINT_MAX)
+          return llvm::Type::UIntTy;
+        else
+          return llvm::Type::ULongTy;
+      }
+    }
+    case RationalTypeID:
+      hlvmNotImplemented("RationalType");
+      break;
     case RealTypeID:
     {
       const RealType *RT = llvm::cast<hlvm::RealType>(ty);





More information about the llvm-commits mailing list