[PATCH] D27123: Add AVR target and toolchain to Clang

Renato Golin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 14 05:03:10 PST 2016


rengolin added a comment.

In https://reviews.llvm.org/D27123#617118, @jroelofs wrote:

> In https://reviews.llvm.org/D27123#616887, @saaadhu wrote:
>
> > Make defines for CHAR16_TYPE, {U,}INT_{LEAST,FAST}16_TYPE use int instead of short.
> >
> > {U,}INT16_TYPE still gets defined as short though - lib/Frontend/InitPreprocessor.cpp::DefineExactWidthIntType does not use TargetInfo::getIntTypeByWidth. Instead, InitializePredefinedMacros calls the function with the specific type (SignedShort/UnsignedShort), as getShortWidth() > getCharWidth(), but getIntWidth() == getShortWidth(). Not sure what the best way to fix that is - should I make DefineExactWidthType use TargetInfo::getIntTypeByWidth?
>
>
> I'm not sure either. I think it's a good question for @rengolin.


Hum, sorry, can't answer that one. :)

I find it confusing that you define `CHAR16` as `int` and `INT16` as `short`, with whatever `INT_FAST16` is as `int`.

I don't know much about AVR, but the C standard predicts that `short` and `int` can have the same size, so Clang should be able to cope with it.

cheers,
--renato



================
Comment at: lib/Basic/Targets.cpp:8543
+  case llvm::Triple::avr:
+    return new AVRTargetInfo(Triple, Opts);
   case llvm::Triple::bpfeb:
----------------
dylanmckay wrote:
> If we build clang without `LLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR`, how will this work?
> 
> Will it fail compilation? Will `clang` report that AVR is supported? Will it crash if you try and run `clang`?
AFAIK, Clang support for targets is independent of LLVM. A standard Clang build supports all targets up to LLVM IR (so all ABIs, PCSs, type descriptions, etc.), but it will fail if the back-end is not available and Clang is invoked beyond IR.

This is why we can only have IR tests in Clang. As long as all your tests stop at IR, this should be fine.


https://reviews.llvm.org/D27123





More information about the cfe-commits mailing list