add dump_code

update-fork
MITSUNARI Shigeo 4 years ago
parent 10621c6299
commit 7146cfd0f4
  1. 3
      Makefile
  2. 7
      src/dump_code.cpp
  3. 26
      src/fp_generator.hpp

@ -237,6 +237,9 @@ endif
$(GEN_EXE): src/gen.cpp src/llvm_gen.hpp
$(CXX) -o $@ $< $(CFLAGS)
src/dump_code: src/dump_code.cpp src/fp.cpp src/fp_generator.hpp
$(CXX) -o $@ src/dump_code.cpp src/fp.cpp -I include -DMCL_FREEZE_JIT -DMCL_MAX_BIT_SIZE=384 -DMCL_DONT_USE_OPENSSL -DMCL_USE_VINT -DMCL_SIZEOF_UNIT=8 -DMCL_VINT_FIXED_BUFFER
asm: $(LLVM_SRC)
$(LLVM_OPT) -O3 -o - $(LLVM_SRC) | $(LLVM_LLC) -O3 $(LLVM_FLAGS) -x86-asm-syntax=intel

@ -0,0 +1,7 @@
#include <mcl/bls12_381.hpp>
int main()
{
mcl::bn::initPairing(mcl::BLS12_381);
}

@ -28,28 +28,31 @@
namespace mcl {
#ifdef MCL_FREEZE_JIT
// not profiler, but dump jit code
struct Profiler {
FILE *fp_;
const uint8_t *prev_;
std::string suf_;
Profiler()
: fp_(0)
: fp_(stdout)
, prev_(0)
{
}
~Profiler()
{
if (fp_) fclose(fp_);
// if (fp_) fclose(fp_);
}
#if 0
void open(const std::string& fileName)
{
fp_ = fopen(fileName.c_str(), "wb");
}
#endif
void setStartAddr(const uint8_t *addr)
{
prev_ = addr;
}
void setNameSuffix(const char *suf)
void setNameSuffix(const std::string& suf)
{
suf_ = suf;
}
@ -71,6 +74,18 @@ struct Profiler {
}
prev_ = end;
}
void dumpData(const void *begin, const void *end)
{
fprintf(fp_, "align 16\n");
fprintf(fp_, "dq ");
const uint64_t *p = (const uint64_t*)begin;
const uint64_t *pe = (const uint64_t*)end;
const size_t n = pe - p;
for (size_t i = 0; i < n; i++) {
fprintf(fp_, "0x%016llx,", (unsigned long long)*p++);
}
fprintf(fp_, "\n");
}
};
#else
typedef Xbyak::util::Profiler Profiler;
@ -314,6 +329,11 @@ private:
for (size_t i = 0; i < op.N; i++) {
dq(op.p[i]);
}
#ifdef MCL_FREEZE_JIT
prof_.dumpData(p_, getCurr());
prof_.setStartAddr(getCurr());
prof_.setNameSuffix(std::string("mclx_") + suf);
#endif
rp_ = fp::getMontgomeryCoeff(p_[0]);
pn_ = (int)op.N;
FpByte_ = int(op.maxN * sizeof(uint64_t));

Loading…
Cancel
Save