void gen2() { const int unit = 64; resetGlobalIdx(); Operand pz(IntPtr, unit); Operand px(IntPtr, unit); Operand py(IntPtr, unit); std::string name = "add128"; Function f(name, Void, pz, px, py); beginFunc(f); Operand x = load(px); Operand y = load(py); x = zext(x, 128); y = zext(y, 128); x = add(x, y); Operand L = trunc(x, 64); store(L, pz); Operand xH = load(getelementptr(px, makeImm(32, 1))); Operand yH = load(getelementptr(py, makeImm(32, 1))); x = trunc(lshr(x, 64), 64); x = add(x, xH); x = add(x, yH); store(x, getelementptr(pz, makeImm(32, 1))); ret(Void); endFunc(); }
int main(int argc, char**argv) { uint32_t arg = demo_value(); uint32_t r = zext((uint8_t) arg); uint32_t s = zext32((uint16_t) arg); if(r != 4 || s != 64516) fail(); return 0; }