[LLVMdev] Proposal: Adding aligned instruction bundle support to MC

Eli Bendersky eliben at google.com
Tue Dec 4 15:53:47 PST 2012


We (the Portable Native Client team) would like to start upstreaming
our LLVM modifications which contain support for Software Fault
Isolation (SFI) as required for sandboxing programs to run under
Native Client. Since the "total patch size" is quite big, we are
splitting the effort to manageable chunks that can be committed,
tested and reviewed separately as independently as feasible.

One of the first things we'd like to start with is support for aligned
instruction bundles in MC (assembler) level. This support exists in
gas since binutils version 2.23
Succinctly, the initial proposal is to add the following directives:

.bundle_align_mode <num>

With the following semantics:

When aligned instruction bundle mode ("bundling" in short) is enabled
(.bundle_align_mode was encountered with an argument > 0, which is the
power of 2 to which the bundle size is equal), single
instructions and groups of instructions between .bundle_lock and
.bundle_unlock directives cannot cross a bundle boundary.

For example, consider the following:

.bundle_align_mode 4

Assuming that each of the mov instructions is 7 bytes long and mov1 is
aligned to a 16-byte boundary, two bytes of NOP padding will be
inserted between mov2 and mov3 to make sure that mov3 does not cross a
16-byte bundle boundary.

A slightly modified example:

.bundle_align_mode 4

Here, since the bundle-locked sequence "mov2 mov3" cannot cross a
bundle boundary, 9 bytes of NOP padding will be inserted between mov1
and mov2.

For information on how this ability is used for software fault
isolation by Native Client, see the following resources:

* http://src.chromium.org/viewvc/native_client/data/site/NaCl_SFI.pdf [PDF link]
* http://www.chromium.org/nativeclient/reference/arm-overview#TOC-The-Native-Client-Solution:-Bundles-
* Other papers listed at

We want to start with this feature because it is self-contained in MC,
makes LLVM more compatible with gas, level and can be easily tested.
Future upstreaming efforts will be able to build upon this

Any comments, ideas and suggestions are welcome.


More information about the llvm-dev mailing list