From 79ccc1598061fcc121a86c78bd71cca39fe34d13 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 18 Feb 2016 11:42:20 +0900 Subject: [PATCH] add fpDbl_add/sub by llvm --- src/short.txt | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/short.txt b/src/short.txt index 931a63f..b340f79 100644 --- a/src/short.txt +++ b/src/short.txt @@ -44,3 +44,49 @@ define void @mcl_fp_sub$(bit)S(i$(bit)* %pz, i$(bit)* %px, i$(bit)* %py, i$(bit) ret void } +@define bu = bit + unit +@define b2 = bit * 2 +@define b2u = b2 + unit +define void @mcl_fpDbl_add$(bit)(i$(bit)* %pz, i$(b2)* %px, i$(b2)* %py, i$(bit)* %pp) { +entry: + %x = load i$(b2)* %px + %y = load i$(b2)* %py + %x1 = zext i$(b2) %x to i$(b2u) + %y1 = zext i$(b2) %y to i$(b2u) + %t0 = add i$(b2u) %x1, %y1 ; x + y = [H:L] + %t1 = trunc i$(b2u) %t0 to i$(bit) ; t1 = L + store i$(bit) %t1, i$(bit)* %pz ; store L + %t2 = shl i$(b2u) %t0, $(bit) + %H = trunc i$(b2u) %t2 to i$(bu) + + %p = load i$(bit)* %pp + %p1 = zext i$(bit) %p to i$(bu) + %Hp = sub i$(bu) %H, %p1 ; H - p + %t3 = lshr i$(bu) %Hp, $(bit) + %t4 = trunc i$(bu) %t3 to i1 + %t5 = select i1 %t4, i$(bu) %H, i$(bu) %Hp + %t6 = trunc i$(bu) %t5 to i$(bit) + %pz1 = getelementptr i$(bit)* %pz, i32 1 + store i$(bit) %t6, i$(bit)* %pz1 + ret void +} + +define void @mcl_fpDbl_sub$(bit)(i$(bit)* %pz, i$(b2)* %px, i$(b2)* %py, i$(bit)* %pp) { + %x = load i$(b2)* %px + %y = load i$(b2)* %py + %x1 = zext i$(b2) %x to i$(b2u) + %y1 = zext i$(b2) %y to i$(b2u) + %vc = sub i$(b2u) %x1, %y1 ; x - y = [H:L] + %L = trunc i$(b2u) %vc to i$(bit) ; L + store i$(bit) %L, i$(bit)* %pz + %vc1 = lshr i$(b2u) %vc, $(bit) + %H = trunc i$(b2u) %vc1 to i$(bit) ; H + %c = lshr i$(b2u) %vc, $(b2u-1) + %c1 = trunc i$(b2u) %c to i1 + %p = load i$(bit)* %pp + %a = select i1 %c1, i$(bit) %p, i$(bit) 0 + %v1 = add i$(bit) %H, %a + %pz1 = getelementptr i$(bit)* %pz, i32 1 + store i$(bit) %v1, i$(bit)* %pz1 + ret void +}