Add arguments to C macros that need them. (#724)
* Add arguments to C macros that need them. Previously no macros took arguments, even those that depended on e.g. XLEN. Old: #define CSR_TDATA1_TYPE_OFFSET (XLEN-4) #define CSR_TDATA1_TYPE_LENGTH 4 #define CSR_TDATA1_TYPE (0xfULL << CSR_TDATA1_TYPE_OFFSET) New: #define CSR_TDATA1_TYPE_OFFSET(XLEN) (XLEN + -4) #define CSR_TDATA1_TYPE_LENGTH 4 #define CSR_TDATA1_TYPE(XLEN) (0xf * (1ULL<<(XLEN + -4))) The new syntax can be a little awkward, but it's correct and works in OpenOCD at least. The most awkward new version is this one: #define DTM_DMI_ADDRESS_OFFSET 0x22 #define DTM_DMI_ADDRESS_LENGTH(abits) abits #define DTM_DMI_ADDRESS(abits) ((0x400000000ULL * (1ULL<<abits)) + -17179869184) Some of the awkwardness stems from the fact that sympy doesn't support a << operator, so I use ** internally and then print it out strangely. It's correct, just not idiomatic. * Tweak how we represent numbers. Add appropriate U and ULL prefix on large hex constants that we negate.
parent
4c0859bf
Please register or sign in to comment