native float type usage in CLR

.net, cil

Solution

From the CIL ECMA spec, I.12.1.1 Native size: native int, native unsigned int, O and &:

The native-size types (native int, native unsigned int, O, and &) are a mechanism in the CLI for deferring the choice of a value’s size. These data types exist as CIL types; however, the CLI maps each to the native size for a specific processor. (For example, data type I would map to int32 on a Pentium processor, but to int64 on an IA64 processor.) So, the choice of size is deferred until JIT compilation or runtime, when the CLI has been initialized and the architecture is known. This implies that field and stack frame offsets are also not known at compile time.

Now, having said that, `native float` (as opposed to `native int`) is not mentioned a single time in the ECMA spec. The only evidence I can find of it is in some open source CIL assemblers, where they throw an exception stating that they cannot generate an opcode for `native float`.

If Microsoft's CIL compiler does in fact accept this type, I would imagine that this was a feature Microsoft intended to implement but did not eventually end up putting into MSIL (CIL's predecessor). Additionally, if the assembler does in fact produce an opcode instead of an error message, I could conceivably imagine (though again, this is speculation) that there may be variant's of Microsoft's CLR (perhaps .NET Micro Framework or a particular version of Silverlight, or something) that supports the opcode.

Also note that in the spec above, the CLI is mentioned. The CLR is merely Microsoft's implementation of the CLI.

The ECMA spec does mention a native floating point type, but it isn't `native float`:

F, a floating point value (float32, float64, or other representation supported by the underlying hardware)

Problem

I have found that CIL compiller allows type `native float`. However, CLR doesn't allow it. Has it any uses? What is its size? Is there a corresponding .NET type? I tried to implement it as a pseudo-primitive type: ``` .class public sequential ansi serializable sealed beforefieldinit NativeFloat extends System.ValueType { .field assembly native float m_value } ``` However, this type isn't supported by CLR. Thank you for your help. Edit: If you're insterested, its CorElementType is 26 (0x1a, R).

Original source