|
|
@ -46,16 +46,14 @@ struct File { |
|
|
|
template<size_t dummy=0> |
|
|
|
template<size_t dummy=0> |
|
|
|
struct Param { |
|
|
|
struct Param { |
|
|
|
static File f; |
|
|
|
static File f; |
|
|
|
|
|
|
|
static int llvmVer; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<size_t dummy> |
|
|
|
template<size_t dummy> |
|
|
|
File Param<dummy>::f; |
|
|
|
File Param<dummy>::f; |
|
|
|
|
|
|
|
|
|
|
|
bool isOldLLVM = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // mcl::impl
|
|
|
|
} // mcl::impl
|
|
|
|
|
|
|
|
|
|
|
|
inline bool isOldLLVM() { return impl::isOldLLVM; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Generator { |
|
|
|
struct Generator { |
|
|
|
static const uint8_t None = 0; |
|
|
|
static const uint8_t None = 0; |
|
|
@ -63,7 +61,14 @@ struct Generator { |
|
|
|
static const uint8_t Imm = 2; |
|
|
|
static const uint8_t Imm = 2; |
|
|
|
static const uint8_t Ptr = 1 << 7; |
|
|
|
static const uint8_t Ptr = 1 << 7; |
|
|
|
static const uint8_t IntPtr = Int | Ptr; |
|
|
|
static const uint8_t IntPtr = Int | Ptr; |
|
|
|
void setOldLLVM() { impl::isOldLLVM = true; } |
|
|
|
int llvmVer; |
|
|
|
|
|
|
|
void setOldLLVM() { llvmVer = 0x37; } |
|
|
|
|
|
|
|
static const int V8 = 0x90; |
|
|
|
|
|
|
|
bool isNewer(int ver) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return llvmVer > ver; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void setLlvmVer(int ver) { llvmVer = ver; } |
|
|
|
struct Type { |
|
|
|
struct Type { |
|
|
|
uint8_t type; |
|
|
|
uint8_t type; |
|
|
|
bool isPtr; |
|
|
|
bool isPtr; |
|
|
@ -474,9 +479,11 @@ inline Generator::Eval Generator::getelementptr(const Generator::Operand& p, con |
|
|
|
Eval e; |
|
|
|
Eval e; |
|
|
|
e.op = p; |
|
|
|
e.op = p; |
|
|
|
e.s = "getelementptr "; |
|
|
|
e.s = "getelementptr "; |
|
|
|
if (!isOldLLVM()) { |
|
|
|
const std::string bit = cybozu::itoa(p.bit); |
|
|
|
e.s += "i" + cybozu::itoa(p.bit) + ", "; |
|
|
|
if (isNewer(V8)) { |
|
|
|
|
|
|
|
e.s += " inbounds " + bit + ", "; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
e.s += "i" + bit + ", "; |
|
|
|
e.s += p.toStr() + ", " + i.toStr(); |
|
|
|
e.s += p.toStr() + ", " + i.toStr(); |
|
|
|
return e; |
|
|
|
return e; |
|
|
|
} |
|
|
|
} |
|
|
@ -493,9 +500,11 @@ inline Generator::Eval Generator::load(const Generator::Operand& p) |
|
|
|
e.op = p; |
|
|
|
e.op = p; |
|
|
|
e.op.type.isPtr = false; |
|
|
|
e.op.type.isPtr = false; |
|
|
|
e.s = "load "; |
|
|
|
e.s = "load "; |
|
|
|
if (!isOldLLVM()) { |
|
|
|
const std::string bit = cybozu::itoa(p.bit); |
|
|
|
e.s += "i" + cybozu::itoa(p.bit) + ", "; |
|
|
|
if (isNewer(V8)) { |
|
|
|
|
|
|
|
e.s += "i" + bit + ", "; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
e.s += "i" + bit + ", "; |
|
|
|
e.s += p.toStr(); |
|
|
|
e.s += p.toStr(); |
|
|
|
return e; |
|
|
|
return e; |
|
|
|
} |
|
|
|
} |
|
|
|