Переглянути джерело

* LLVM-specific support for popcnt

git-svn-id: trunk@42311 -
Jonas Maebe 6 роки тому
батько
коміт
789f13eb24
2 змінених файлів з 12 додано та 0 видалено
  1. 7 0
      compiler/llvm/nllvminl.pas
  2. 5 0
      rtl/inc/llvmintr.inc

+ 7 - 0
compiler/llvm/nllvminl.pas

@@ -41,6 +41,7 @@ interface
         function first_sqr_real: tnode; override;
         function first_sqrt_real: tnode; override;
         function first_trunc_real: tnode; override;
+        function first_popcnt: tnode; override;
        public
         procedure second_length; override;
         procedure second_sqr_real; override;
@@ -284,6 +285,12 @@ implementation
           result:=inherited;
       end;
 
+    function tllvminlinenode.first_popcnt: tnode;
+      begin
+        result:=ctypeconvnode.create(ccallnode.createintern('LLVM_CTPOP', ccallparanode.create(left,nil)),resultdef);
+        left:=nil;
+      end;
+
 
     procedure tllvminlinenode.second_length;
       var

+ 5 - 0
rtl/inc/llvmintr.inc

@@ -35,6 +35,11 @@ function llvm_cttz(src: UInt16; is_zero_undef: LLVMBool1): UInt16; external name
 function llvm_cttz(src: UInt32; is_zero_undef: LLVMBool1): UInt32; external name 'llvm.cttz.i32';
 function llvm_cttz(src: UInt64; is_zero_undef: LLVMBool1): UInt64; external name 'llvm.cttz.i64';
 
+function llvm_ctpop(src: UInt8): UInt8; external name 'llvm.ctpop.i8';
+function llvm_ctpop(src: UInt16): UInt16; external name 'llvm.ctpop.i16';
+function llvm_ctpop(src: UInt32): UInt32; external name 'llvm.ctpop.i32';
+function llvm_ctpop(src: UInt64): UInt64; external name 'llvm.ctpop.i64';
+
 function llvm_sqrt_f32(val: single): single; compilerproc; external name 'llvm.sqrt.f32';
 function llvm_sqrt_f64(val: double): double; compilerproc; external name 'llvm.sqrt.f64';
 {$ifdef SUPPORT_EXTENDED}