[LLVMdev] [PATCH] OpenCL half support

Chris Lattner clattner at apple.com
Wed Jul 13 23:42:55 PDT 2011


On Jul 13, 2011, at 4:26 AM, Anton Lokhmotov wrote:

> Hi Chris,
> 
> We have updated the half patch for TOT.  Could you review please?

Sorry for the delay, some thoughts:

+++ b/include/llvm/Bitcode/LLVMBitCodes.h
@@ -110,10 +110,12 @@ namespace bitc {
     TYPE_CODE_METADATA = 16,    // METADATA
 
     TYPE_CODE_X86_MMX = 17,     // X86 MMX
+
+    TYPE_CODE_HALF     = 18,    //  IEEE HALF (16-bit fp)
     
-    TYPE_CODE_STRUCT_ANON = 18, // STRUCT_ANON: [ispacked, eltty x N]
-    TYPE_CODE_STRUCT_NAME = 19, // STRUCT_NAME: [strchr x N]
-    TYPE_CODE_STRUCT_NAMED = 20 // STRUCT_NAMED: [ispacked, eltty x N]
+    TYPE_CODE_STRUCT_ANON = 19, // STRUCT_ANON: [ispacked, eltty x N]
+    TYPE_CODE_STRUCT_NAME = 20, // STRUCT_NAME: [strchr x N]
+    TYPE_CODE_STRUCT_NAMED = 21 // STRUCT_NAMED: [ispacked, eltty x N]


Please make TYPE_CODE_HALF be "21" at the end of the list.  Bitcode id's are not allowed to ever change.


+++ b/include/llvm/Type.h
     VectorTyID,      ///< 14: SIMD 'packed' format, or other vector type

+    HalfTyID,        ///< 16: 16-bit floating-point type

The comment is wrong, it should be "15:"


The rest of the patch looks like a reasonable first start, but doesn't include code generation or optimizer changes.  The code generator will certainly need changes to emit global variables with half floats in them (among other things) and I would expect a variety of optimizer changes scattered in for various stuff that needs to touch half floats.

-Chris





More information about the llvm-dev mailing list