[cfe-dev] FW: patch for generalizing stdint for n-bit bytes
Ken Dyck
Ken.Dyck at onsemi.com
Thu Oct 29 07:52:58 PDT 2009
> On Thursday, October 29, 2009 12:59 AM, Chris Lattner wrote:
> On Oct 22, 2009, at 5:12 AM, Ken Dyck wrote:
> >> Please propose a patch that just uses the new methods you added to
> >> simplify InitPreprocessor without changing the other
> behavior. That
> >> will make it easier to review the patch and it will be
> more obviously
> >> correct (and can thus be applied without thinking) :)
> >
> > Is the attached patch what you have in mind? Or would you
> like to see
> > a more aggressive refactoring to remove all of the literal
> type names
> > and constant suffixes from InitPreprocessor.cpp?
>
> This is a great start, applied as r85481. Removing the rest would be
> even better :)
One obstacle I found to simplifying the code is that the char type is
not included in the TargetInfo::IntTy enumeration, making it necessary
to always add a special case for characters. What is the rational for
excluding characters? Would there be any objection to adding a Char type
to the enum?
> >> The changes to stdint.h are difficult to understand from the patch,
> >> but look basically reasonable to me. In the next round of patches,
> >> I'll look closer. Just to verify, on boring targets where bytes
> >> are 8 bits, no extra definitions will come out of it (other than
> >> the new WIDTH macros)?
> >
> > There aren't any additional user macros, but there are a few more
> > implementation macros. Some are for the SIG_ATOMIC
> definitions, which
> > were previously hard-coded as 32-bit integers. There are
> also some new
> > SIGNED macros so stdint.h can define the correct limits for
> the types
> > that can can be either signed or unsigned.
>
> Ok. Please send this as a follow on patch.
Okay. FYI, this is the plan I'll be working from for future patches:
1. A simple reordering of typedefs in stdint.h (and corresponding test
cases) in anticipation of the next patch, which defines the types in
order of decreasing width.
2. Generalization of stdint.h for non-power-of-2 widths, along with
necessary modifications to InitPreprocessor.cpp. Only minor changes to
test cases (where long is replaced by int in some typedefs on targets
where they are the same width).
3. Parameterization of SIG_ATOMIC
4. Parameterization of limits on types that can be either signed or
unsigned.
5. Replace use of vector<char> for the definition buffer with a
raw_ostream.
Does that seem reasonable to you?
-Ken
More information about the cfe-dev
mailing list