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

David Woodhouse dwmw2 at infradead.org
Thu Jan 23 03:13:57 PST 2014


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
 ^^^
 


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.

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.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse at intel.com                              Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140123/0491c72c/attachment.bin>


More information about the cfe-commits mailing list