Adding a floating point type in an odd way.

Hello everyone,

I've got a strange situation where the path forward is unclear to me,
so I could use some advice. Also posted to the #beginners channel on

My target machine handles three different types of 16-bit floating
point values, but only one for any given compilation: which one is
used depends on the setting of a memory-mapped config register, and
they all use the same set of instructions. The only real difference
during compilation is how their constants are interpreted for initial
values and constant folding, so for supporting all three types, I'm
trying to limit changes to APFloat.

Ideally I'd like to have "half" in source and HalfTy internally
represent all of them, and add a command line option to use separate
APFloat handling and fltSemantics as appropriate. I think (but I may
be wrong) that three separate types would result in a lot of
duplication in the backend and intrinsics. I don't want to do a
storage-only type like bfloat if I can avoid it.

The question (finally): does any other target have this kind of setup:
if so, how do they do it? If not, how should I do it? I'm running into
an issue within ConstantFP (llvm/lib/IR/Constants.cpp): the only
structure around that could provide the type information is
LLVMContext(Impl), and I haven't figured out a way to modify that
appropriately. I also need to ensure that separate compiles don't have
conflicting type settings, and I don't know how that would be done in
this situation: presumably some kind of Module metadata, which I don't
know the location of.

I was told AMDGPU might have something of this nature. Any advice is
welcome: I spend all my time on backend passes, so fiddling with the
core of LLVM is new to me.