[PATCH] Add -m16 option for using x86-*-*-code16 triple

Alp Toker alp at nuanti.com
Thu Jan 23 03:56:40 PST 2014


On 23/01/2014 11:13, David Woodhouse wrote:
> On Wed, 2014-01-22 at 17:52 +0000, Alp Toker wrote:
>> -m16 is special so it'll be good to document the feature and its
>> intended usage for end users, perhaps somewhere in
>> docs/UsersManual.rst.
> Like this?
>
> diff --git a/docs/UsersManual.rst b/docs/UsersManual.rst
> index fb5cda5..df25737 100644
> --- a/docs/UsersManual.rst
> +++ b/docs/UsersManual.rst
> @@ -1332,6 +1332,13 @@ On ``x86_64-mingw32``, passing i128(by value) is incompatible with the
>   Microsoft x64 calling conversion. You might need to tweak
>   ``WinX86_64ABIInfo::classify()`` in lib/CodeGen/TargetInfo.cpp.
>   
> +For the X86 target, clang supports the :option:`-m16` command line argument
> +which enables 16-bit code output. This is broadly similar to using
> +``asm(".code16gcc")`` with the GNU toolchain. The generated code and the ABI
> +remains 32-bit but the assembler emits instructions appropriate for a CPU
> +running in 16-bit mode, with address-size and operand-size prefixes to enable
> +32-bit addressing and operations.
> +
>   ARM
>   ^^^

Looks good. Also is that a typo for 'convention' in the context above?


>   
>
>
> It would also be interesting to support .code16gcc as discussed. We can
> make clang include that in its asm output to make -m16 with with
> -no-integrated-as, and if we're going to do that then we should first
> make the LLVM assembler handle .code16gcc. That isn't *so* hard — we
> just need to split the meaning of the 'In16BitMode' predicate and use
> one instance of it for the actual code emission, and another for all
> those InstAliases which make e.g. "ret" translate into "retw"
> for .code16 mode, and "retl" for .code32 or .code16gcc.

Yeah, that'd round things off.

>
> There's a third use of In16BitMode which is for hiding instructions that
> are *only* available in 16-bit mode. But actually, Craig was talking
> about removing that use of it since *all* 16-bit instructions are also
> available in 32-bit mode with an OpSize prefix.
>

-- 
http://www.nuanti.com
the browser experts




More information about the cfe-commits mailing list