move unit, bit, N to derived class

dev
MITSUNARI Shigeo 9 years ago
parent ab390ce3ec
commit abbefb9109
  1. 7
      src/gen.cpp
  2. 13
      src/llvm_gen.hpp

@ -1,6 +1,9 @@
#include "llvm_gen.hpp" #include "llvm_gen.hpp"
struct OnceCode : public mcl::Generator { struct OnceCode : public mcl::Generator {
uint32_t unit;
uint32_t bit;
uint32_t N;
uint32_t unit2; uint32_t unit2;
Function mulUU; Function mulUU;
Function extractHigh; Function extractHigh;
@ -54,7 +57,9 @@ struct OnceCode : public mcl::Generator {
} }
void gen(uint32_t unit, uint32_t bit) void gen(uint32_t unit, uint32_t bit)
{ {
set(unit, bit); this->unit = unit;
this->bit = bit;
N = bit / unit;
unit2 = unit * 2; unit2 = unit * 2;
gen_mulUU(); gen_mulUU();
gen_extractHigh(); gen_extractHigh();

@ -66,22 +66,11 @@ struct Generator {
, isPtr((type & Ptr) != 0) , isPtr((type & Ptr) != 0)
{ {
} }
static inline friend std::ostream& operator<<(std::ostream& os, const Type& self) inline friend std::ostream& operator<<(std::ostream& os, const Type& self)
{ {
return os << (self.type | (self.isPtr ? Ptr : 0)); return os << (self.type | (self.isPtr ? Ptr : 0));
} }
}; };
Type type;
uint32_t unit;
uint32_t bit;
uint32_t N;
Generator() : unit(0), bit(0), N(0) {}
void set(uint32_t unit, uint32_t bit)
{
this->unit = unit;
this->bit = bit;
this->N = bit / unit;
}
void open(const std::string& file) void open(const std::string& file)
{ {
impl::Param<>::f.open(file); impl::Param<>::f.open(file);

Loading…
Cancel
Save