short.txt is removed

dev
MITSUNARI Shigeo 9 years ago
parent 6ba5a3f71e
commit 6efaed4fda
  1. 2
      Makefile
  2. 35
      src/gen.cpp
  3. 1
      src/gen.py
  4. 23
      src/short.txt

@ -14,7 +14,7 @@ SAMPLE_SRC=bench.cpp ecdh.cpp random.cpp rawbench.cpp vote.cpp
MCL_LIB=$(LIB_DIR)/libmcl.a
all: $(MCL_LIB)
ASM_SRC_TXT=long.txt short.txt mul.txt
ASM_SRC_TXT=long.txt mul.txt
LIB_OBJ=$(OBJ_DIR)/$(CPU).o $(OBJ_DIR)/fp.o
LLVM_VER=-3.6
LLVM_LLC=llc$(LLVM_VER)

@ -348,6 +348,7 @@ struct Code : public mcl::Generator {
}
void gen_mcl_fpDbl_add()
{
// QQQ : generate unnecessary memory copy for large bit
const int bu = bit + unit;
const int b2 = bit * 2;
const int b2u = b2 + unit;
@ -381,6 +382,39 @@ struct Code : public mcl::Generator {
ret(Void);
endFunc();
}
void gen_mcl_fpDbl_sub()
{
// QQQ : rol is used?
const int b2 = bit * 2;
const int b2u = b2 + unit;
resetGlobalIdx();
Operand pz(IntPtr, bit);
Operand px(IntPtr, b2);
Operand py(IntPtr, b2);
Operand pp(IntPtr, bit);
std::string name = "mcl_fpDbl_sub" + cybozu::itoa(bit);
Function f(name, Void, pz, px, py, pp);
beginFunc(f);
Operand x = load(px);
Operand y = load(py);
x = zext(x, b2u);
y = zext(y, b2u);
Operand vc = sub(x, y); // x - y = [H:L]
Operand L = trunc(vc, bit);
store(L, pz);
Operand H = lshr(vc, bit);
H = trunc(H, bit);
Operand c = lshr(vc, b2u - 1);
c = trunc(c, 1);
Operand p = load(pp);
c = select(c, p, makeImm(bit, 0));
Operand t = add(H, c);
pz = getelementptr(pz, makeImm(32, 1));
store(t, pz);
ret(Void);
endFunc();
}
void gen_all()
{
gen_mcl_fp_addsubNC(true);
@ -391,6 +425,7 @@ struct Code : public mcl::Generator {
gen_mcl_fp_add();
gen_mcl_fp_sub();
gen_mcl_fpDbl_add();
gen_mcl_fpDbl_sub();
}
void setBit(uint32_t bit)
{

@ -181,7 +181,6 @@ def main():
fo.write(a)
bitLL = range(unitL, 576 + 1, unitL)
gen(fo, 'short.txt', unitL, bitLL)
gen(fo, 'long.txt', unitL, bitLL)
gen(fo, 'mul.txt', unitL, bitLL[1:])
fo.close()

@ -1,23 +0,0 @@
@define bu = bit + unit
@define b2 = bit * 2
@define b2u = b2 + unit
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
}
Loading…
Cancel
Save