Add a helper method
[oota-llvm.git] / include / llvm / Intrinsics.td
index 13cb41b5179d3ecdecbad2ac5af198af754be289..2d34ce037a90d2bf64e7d18cfea7dce2fadd998b 100644 (file)
@@ -54,6 +54,11 @@ class LLVMType<string typeval> {
   string TypeVal = typeval;
 }
 
+class LLVMPackedType<int numelts, LLVMType elty> : LLVMType<"Type::PackedTyID">{
+  int NumElts = numelts;
+  LLVMType ElTy = elty;
+} 
+
 def llvm_void_ty       : LLVMType<"Type::VoidTyID">;
 def llvm_bool_ty       : LLVMType<"Type::BoolTyID">;
 def llvm_sbyte_ty      : LLVMType<"Type::SByteTyID">;
@@ -68,9 +73,12 @@ def llvm_float_ty      : LLVMType<"Type::FloatTyID">;
 def llvm_double_ty     : LLVMType<"Type::DoubleTyID">;
 def llvm_ptr_ty        : LLVMType<"Type::PointerTyID">;     // sbyte*
 def llvm_ptrptr_ty     : LLVMType<"Type::PointerTyID">;     // sbyte**
-def llvm_anchor_ty     : LLVMType<"Type::PointerTyID">;     // {}*
 def llvm_descriptor_ty : LLVMType<"Type::PointerTyID">;     // global*
 
+def llvm_v4i32_ty      : LLVMPackedType<4, llvm_int_ty>;    // 4 x int
+def llvm_v4f32_ty      : LLVMPackedType<4, llvm_float_ty>;  // 4 x float
+def llvm_v2f64_ty      : LLVMPackedType<4, llvm_double_ty>; // 2 x double
+
 //===----------------------------------------------------------------------===//
 // Intrinsic Definitions.
 //===----------------------------------------------------------------------===//
@@ -88,10 +96,18 @@ class Intrinsic<list<LLVMType> types,
                 list<IntrinsicProperty> properties = [],
                 string name = ""> {
   string LLVMName = name;
+  string TargetPrefix = "";   // Set to a prefix for target-specific intrinsics.
   list<LLVMType> Types = types;
   list<IntrinsicProperty> Properties = properties;
 }
 
+/// GCCBuiltin - If this intrinsic exactly corresponds to a GCC builtin, this
+/// specifies the name of the builtin.  This provides automatic CBE and CFE
+/// support.
+class GCCBuiltin<string name> {
+  string GCCBuiltinName = name;
+}
+
 
 //===--------------- Variable Argument Handling Intrinsics ----------------===//
 //  
@@ -104,16 +120,17 @@ def int_vaend   : Intrinsic<[llvm_void_ty, llvm_ptrptr_ty], [], "llvm.va_end">;
 //===------------------- Garbage Collection Intrinsics --------------------===//
 //  
 def int_gcroot  : Intrinsic<[llvm_void_ty, llvm_ptrptr_ty, llvm_ptr_ty]>;
-def int_gcread  : Intrinsic<[llvm_ptr_ty, llvm_ptrptr_ty], [InstrReadArgMem]>;
-def int_gcwrite : Intrinsic<[llvm_void_ty, llvm_ptr_ty, llvm_ptrptr_ty],
-                            [InstrWriteArgMem]>;
+def int_gcread  : Intrinsic<[llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty],
+                            [InstrReadArgMem]>;
+def int_gcwrite : Intrinsic<[llvm_void_ty, llvm_ptr_ty, llvm_ptr_ty,
+                             llvm_ptrptr_ty], [InstrWriteArgMem]>;
 
 //===--------------------- Code Generator Intrinsics ----------------------===//
 //  
 def int_returnaddress : Intrinsic<[llvm_ptr_ty, llvm_uint_ty], [InstrNoMem]>;
 def int_frameaddress  : Intrinsic<[llvm_ptr_ty, llvm_uint_ty], [InstrNoMem]>;
-def int_stacksave     : Intrinsic<[llvm_ptr_ty]>;
-def int_stackrestore  : Intrinsic<[llvm_ptr_ty]>;
+def int_stacksave     : Intrinsic<[llvm_ptr_ty], [IntrReadMem]>;
+def int_stackrestore  : Intrinsic<[llvm_void_ty, llvm_ptr_ty]>;
 def int_prefetch      : Intrinsic<[llvm_void_ty, llvm_ptr_ty, 
                                    llvm_uint_ty, llvm_uint_ty]>;
 def int_pcmarker      : Intrinsic<[llvm_void_ty, llvm_uint_ty]>;
@@ -139,8 +156,10 @@ let Properties = [InstrWriteArgMem] in {
 }
 
 let Properties = [InstrNoMem] in {
-  def int_isunordered_f32 : Intrinsic<[llvm_float_ty,  llvm_float_ty]>;
-  def int_isunordered_f64 : Intrinsic<[llvm_double_ty, llvm_double_ty]>;
+  def int_isunordered_f32 : Intrinsic<[llvm_bool_ty, 
+                                       llvm_float_ty,  llvm_float_ty]>;
+  def int_isunordered_f64 : Intrinsic<[llvm_bool_ty, 
+                                       llvm_double_ty, llvm_double_ty]>;
   def int_sqrt_f32 : Intrinsic<[llvm_float_ty , llvm_float_ty]>;
   def int_sqrt_f64 : Intrinsic<[llvm_double_ty, llvm_double_ty]>;
 }
@@ -179,10 +198,34 @@ let Properties = [InstrNoMem] in {
 //===------------------------ Debugger Intrinsics -------------------------===//
 //
 
-def int_dbg_stoppoint    : Intrinsic<[llvm_anchor_ty, llvm_uint_ty, 
-                                      llvm_uint_ty, llvm_descriptor_ty]>;
-def int_dbg_region_start : Intrinsic<[llvm_anchor_ty, llvm_anchor_ty]>;
-def int_dbg_region_end   : Intrinsic<[llvm_anchor_ty, llvm_anchor_ty]>;
-def int_dbg_func_start   : Intrinsic<[llvm_anchor_ty, llvm_descriptor_ty]>;
-//    dbg_declare,      // Declare a local object
+def int_dbg_stoppoint    : Intrinsic<[llvm_void_ty,
+                                      llvm_uint_ty, llvm_uint_ty, 
+                                      llvm_descriptor_ty]>;
+def int_dbg_region_start : Intrinsic<[llvm_void_ty]>;
+def int_dbg_region_end   : Intrinsic<[llvm_void_ty]>;
+def int_dbg_func_start   : Intrinsic<[llvm_void_ty, llvm_descriptor_ty]>;
+
 
+//===----------------------------------------------------------------------===//
+// Target-specific intrinsics
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+// PowerPC Intrinsics
+//
+let TargetPrefix = "ppc" in {  // All intrinsics start with "llvm.ppc.".
+  def int_ppc_altivec_lvx : GCCBuiltin<"__builtin_altivec_lvx">,
+              Intrinsic<[llvm_v4i32_ty, llvm_int_ty, llvm_ptr_ty],
+                        [IntrReadMem]>;
+  def int_ppc_altivec_stvx : GCCBuiltin<"__builtin_altivec_stvx">,
+              Intrinsic<[llvm_void_ty, llvm_v4i32_ty, llvm_int_ty, llvm_ptr_ty],
+                        [IntrWriteMem]>;
+                            
+  def int_ppc_altivec_vmaddfp : GCCBuiltin<"__builtin_altivec_vmaddfp">,
+              Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty,
+                         llvm_v4f32_ty, llvm_v4f32_ty], [InstrNoMem]>;
+  def int_ppc_altivec_vadduwm : GCCBuiltin<"__builtin_altivec_vadduwm">,
+              Intrinsic<[llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
+                        [InstrNoMem]>;
+  
+}