Skip to content

Code generation for typed literals

I include literal numpy values in my instruction stream at some points, for example numpy.int64(1). What's the right way to ensure that these are turned into 1L, not 1 in the target? The latter is wrong. Consider, for example LeftShift(numpy.int64(1), numpy.int64(35)). Currently I get: 1 << 35 which overflows, because nbits(1) < 16, so C infers an unsigned (or maybe int) type for 1. I need to instead say 1L << 35, which enforces that the value is a 64bit int. I'd be happy with #include <stdint.h> and (int64_t)1 too. Although insertion of floating point literals is messier I think.