OSDN Git Service

android-x86/external-swiftshader.git
8 years agoSubzero. ARM32. Combine allocas.
John Porto [Mon, 23 Nov 2015 19:43:13 +0000 (11:43 -0800)]
Subzero. ARM32. Combine allocas.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1465213002 .

8 years agoSubzero: Add a makefile config for building with g++.
Jim Stichnoth [Sun, 22 Nov 2015 14:06:34 +0000 (06:06 -0800)]
Subzero: Add a makefile config for building with g++.

This way, the g++ build for the "make presubmit" target gets a separate build directory, and gets to use ccache.

Also, get rid of the "git diff" test, because uncommitted changes are already checked by "git cl upload" and "git cl land".

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1468823002 .

8 years agoCompute the size of the stack space required to send the parameters to a call.
David Sehr [Sat, 21 Nov 2015 05:09:31 +0000 (21:09 -0800)]
Compute the size of the stack space required to send the parameters to a call.

BUG=
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1458713002 .

8 years agoAdd recognizing register-shifted forms in ARM assembler.
Karl Schimpf [Fri, 20 Nov 2015 22:42:33 +0000 (14:42 -0800)]
Add recognizing register-shifted forms in ARM assembler.

Extends the ARM integrated assembler to understand register-shifted
data processing instructions (add, sub, etc.), as well as cmp/test
instructions.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1459673003 .

8 years agoAdd MVN (register, immediate) to ARM integrated assembler.
Karl Schimpf [Fri, 20 Nov 2015 22:26:12 +0000 (14:26 -0800)]
Add MVN (register, immediate) to ARM integrated assembler.

Also removes redundant rule checks in emitType01().

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1460523005 .

8 years agoSubzero. ARM32. No more SP frobbing.
John Porto [Fri, 20 Nov 2015 22:17:23 +0000 (14:17 -0800)]
Subzero. ARM32. No more SP frobbing.

Pre-computes the max stack size outgoing arguments, and pre-allocates
it during prolog, deallocating during epilog.

With this CL, there are no more StackAdjustments needed for the ARM32,
which will simplify rematerializing alloca'd variables.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=sehr@chromium.org

Review URL: https://codereview.chromium.org/1467473003 .

8 years agoSubzero. Adds a pass for target-specific helper call generation.
John Porto [Fri, 20 Nov 2015 21:50:36 +0000 (13:50 -0800)]
Subzero. Adds a pass for target-specific helper call generation.

This pass gives Targets the ability to pre-lower high-level
instructions that will later be lowered to a target-specific helper,
e.g., 64-bit division on targets that can't natively handle them.

This is a pre-requirement for correct outargs pre-allocation during
function prolog.

R=sehr@chromium.org

Review URL: https://codereview.chromium.org/1455033005 .

8 years agoFix race condition in jump table list creation
David Sehr [Fri, 20 Nov 2015 05:47:15 +0000 (21:47 -0800)]
Fix race condition in jump table list creation

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1460003003 .

8 years agoAdd LSL (register, immediate) to ARM integrated assembler.
Karl Schimpf [Thu, 19 Nov 2015 16:10:44 +0000 (08:10 -0800)]
Add LSL (register, immediate) to ARM integrated assembler.

Also does some clean up on emitType01 methods (making optional argument
explicit, and moving rule checks to the lowest level).

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1456783003 .

8 years agoSubzero. ARM32. Removes memory legalization warts.
John Porto [Thu, 19 Nov 2015 13:42:59 +0000 (05:42 -0800)]
Subzero. ARM32. Removes memory legalization warts.

This CL removes two warts from the ARM32 backend:
1) during argument lowering, if a stack parameter is assigned a
register, the backend creates a new Variable that references the stack
location with the incoming argument, and _mov() it to the parameter.

2) During stack slot legalization, all _mov(Mem(), Reg) are converted to
stores; and all _mov(Reg, Mem()) are converted to loads.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1457683004 .

8 years agoAdd BL (immediate) and BLX (register) to ARM assembler.
Karl Schimpf [Wed, 18 Nov 2015 16:19:26 +0000 (08:19 -0800)]
Add BL (immediate) and BLX (register) to ARM assembler.

Adds BL and BLX to ARM integrated assembler.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1452293003 .

8 years agoMake more visible with doxygen.
Jim Stichnoth [Wed, 18 Nov 2015 14:25:46 +0000 (06:25 -0800)]
Make more visible with doxygen.
To see the main effect of this, look at the doxygen for file
IceGlobalContext.h to see the effect of turning this on.
Without it, the nested classes are not available because they
are private.

My guess is that often doxygen is used to generate API documents and for that reason, exporting of private info is excluded by default.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1411123019 .

8 years agoSubzero. ARM32. Introduces the ShAmtImm Operand.
John Porto [Tue, 17 Nov 2015 22:31:25 +0000 (14:31 -0800)]
Subzero. ARM32. Introduces the ShAmtImm Operand.

Creates a special OperandARM32 for representing imm5 used when
performing a shift operation.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1449263003 .

8 years agoAdd LDR/LDRB (register) to ARM integrated assembler.
Karl Schimpf [Tue, 17 Nov 2015 22:02:02 +0000 (14:02 -0800)]
Add LDR/LDRB (register) to ARM integrated assembler.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1458523002 .

8 years agoSubzero: Improve the "make check-presubmit" target.
Jim Stichnoth [Tue, 17 Nov 2015 14:14:05 +0000 (06:14 -0800)]
Subzero: Improve the "make check-presubmit" target.

1. Include a test build (but no link) using g++, to identify errors and warnings before they hit the Windows bots.

2. Move "git diff --quiet" to the end so that the presubmit tests can easily be run before committing locally, if desired.

3. Add "make presubmit" as an alias for "make check-presubmit".

4. Document the individual steps.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1453713002 .

8 years agoSubzero. ARM32. Improve constant lowering.
John Porto [Tue, 17 Nov 2015 12:58:36 +0000 (04:58 -0800)]
Subzero. ARM32. Improve constant lowering.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1438773004 .

8 years agoSubzero: Fix build warnings/errors under g++.
Jim Stichnoth [Tue, 17 Nov 2015 05:40:20 +0000 (21:40 -0800)]
Subzero: Fix build warnings/errors under g++.

BUG= none
TEST= make -j32 -f Makefile.standalone CXX=g++ LLVM_EXTRA_WARNINGS="-Wno-unknown-pragmas -Wno-unused-parameter -Wno-comment -Wno-enum-compare -Wno-strict-aliasing" STDLIB_FLAGS=
(this command will compile but fail to link)

R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1452993002 .

8 years agoSubzero: Fix a performance regression in the register allocator.
Jim Stichnoth [Tue, 17 Nov 2015 01:17:48 +0000 (17:17 -0800)]
Subzero: Fix a performance regression in the register allocator.

The register allocator does not need to be considering rematerializable variables at all.  When it does, there tends to be a big performance cost because the live range of a rematerializable variable tends to be large, leading to lots of expensive overlap computations against register allocation candidates.

BUG= none
R=jpp@chromium.org, sehr@chromium.org

Review URL: https://codereview.chromium.org/1450233002 .

8 years agoReserve space for scalar FP returns in the stack frame
David Sehr [Tue, 17 Nov 2015 01:00:38 +0000 (17:00 -0800)]
Reserve space for scalar FP returns in the stack frame

Rather than bumping the stack pointer around the scalar return sequence in
_fld, ensure the prolog allocates enough space.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1442753008 .

8 years agoMerge fixed alloca stack adjustments into the prolog
David Sehr [Tue, 17 Nov 2015 00:51:39 +0000 (16:51 -0800)]
Merge fixed alloca stack adjustments into the prolog

Also removes reliance on lowerAlloca entirely for the fixed allocations.

BUG=
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1435363002 .

8 years agoSubzero: Do some cleanup on the regalloc code.
Jim Stichnoth [Mon, 16 Nov 2015 23:59:39 +0000 (15:59 -0800)]
Subzero: Do some cleanup on the regalloc code.

No functional changes, as measured by identical spec2k asm output.

1. Use early "return" and "continue" to reduce "if" nesting.

2. Reflow comments to 80 columns (instead of presumably 79).

3. Add some BuildDefs::dump() tests to reduce translator code size.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1448773002 .

8 years agoSubzero: Add a "make check-presubmit" target.
Jim Stichnoth [Mon, 16 Nov 2015 20:47:57 +0000 (12:47 -0800)]
Subzero: Add a "make check-presubmit" target.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1452553002 .

8 years agoFix translation of instruction "move" in ARM integrated assembler.
Karl Schimpf [Mon, 16 Nov 2015 20:38:12 +0000 (12:38 -0800)]
Fix translation of instruction "move" in ARM integrated assembler.

Fixes case where the ARM integrated assembler for class InstARM32Mov
did not revert to using the stand-alone assembler (method emit) to
generate the corresponding assembly instructions(s).

This fixes last known problem with method emitIAS (other than
reverting to the stand-alone assembler if not implemented). Removes
use of workaround flag "-unsafe-ias".

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1448783004 .

8 years agoFix MINIMAL=1 build
David Sehr [Sat, 14 Nov 2015 00:59:02 +0000 (16:59 -0800)]
Fix MINIMAL=1 build

Lots of definitions of Target outside of asserts.

BUG=

Review URL: https://codereview.chromium.org/1448673002 .

8 years agoEliminate stack adjustment for float-returning functions
David Sehr [Sat, 14 Nov 2015 00:32:37 +0000 (16:32 -0800)]
Eliminate stack adjustment for float-returning functions

This involves changing AdjustStack to grow/shrink the stack, and to use that
operation exclusively to move the StackAdjustment variable in lowering, rather
than in call emission as before.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1449523002 .

8 years agoSubzero: Find rematerializable variables transitively.
Jim Stichnoth [Fri, 13 Nov 2015 22:28:23 +0000 (14:28 -0800)]
Subzero: Find rematerializable variables transitively.

There are situations where a variable is assigned as the result of a rematerializable alloca instruction, and then another variable is assigned as essentially a known-offset interior pointer into the alloca space.  In this case, the secondary variable is also rematerializable.

We add a pass, after alloca analysis, to find these derived variables and mark them transitively as rematerializable.  Because we lack use-def chains (or in fact any map to variable use locations), we need to iterate over the CFG until convergence.  Fortunately, this is pretty cheap, and not even done unless the alloca analysis seeds it with an initial set of rematerializable variables.

This analysis is only really needed for arithmetic instructions, but we also need to apply it to assignments and pointer-type bitcasts that are added when the IceConverter directly parses a .ll file rather than a .pexe file.

BUG= none
R=jpp@chromium.org, sehr@chromium.org

Review URL: https://codereview.chromium.org/1441793002 .

8 years agoSubzero: Use "pxor reg,reg" to load a floating-point scalar 0.0 value.
Jim Stichnoth [Fri, 13 Nov 2015 22:20:40 +0000 (14:20 -0800)]
Subzero: Use "pxor reg,reg" to load a floating-point scalar 0.0 value.

BUG= none
R=jpp@chromium.org, sehr@chromium.org

Review URL: https://codereview.chromium.org/1439363002 .

8 years agoAdd a getTarget method that returns the x86 target lowering
David Sehr [Thu, 12 Nov 2015 22:41:22 +0000 (14:41 -0800)]
Add a getTarget method that returns the x86 target lowering

Remove a bit of complex repeated template naming.

BUG=
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1438933002 .

8 years agoSubzero: Fix a crash in mem operand dumping.
Jim Stichnoth [Thu, 12 Nov 2015 18:26:34 +0000 (10:26 -0800)]
Subzero: Fix a crash in mem operand dumping.

getOffset() was being dereferenced even when it was nullptr.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1435283003 .

8 years agoSubzero: Add "--verbose=status" option.
Jim Stichnoth [Thu, 12 Nov 2015 18:25:21 +0000 (10:25 -0800)]
Subzero: Add "--verbose=status" option.

This just prints the function being translated, once per function.  This is useful if there is a crash or fatal error somewhere, and you want to quickly discover which function to set -verbose-focus on.

Also, fixes some warnings/errors in the MINIMAL build.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1439983002 .

8 years agoFix push/pop emit methods for ARM assembler.
Karl Schimpf [Thu, 12 Nov 2015 18:12:14 +0000 (10:12 -0800)]
Fix push/pop emit methods for ARM assembler.

These two methods introduce multiple instructions. Between each
instruction a newline must be inserted, and a call to startNextInt().
This CL makes sure both cases are met.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1441023002 .

8 years agoImplement UXTB and UXTH in the ARM integerated assembler.
Karl Schimpf [Wed, 11 Nov 2015 23:42:55 +0000 (15:42 -0800)]
Implement UXTB and UXTH in the ARM integerated assembler.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1432413003 .

8 years agoFix frame pointer loads/stores in the ARM integrated assembler.
Karl Schimpf [Wed, 11 Nov 2015 23:37:50 +0000 (15:37 -0800)]
Fix frame pointer loads/stores in the ARM integrated assembler.

This CL passes in context from the ARM target lowering, so that
it can figure out what register (SP or FP) and offset to use
when loading/storing variables.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1414043015 .

8 years agoCombine allocas
David Sehr [Wed, 11 Nov 2015 23:01:55 +0000 (15:01 -0800)]
Combine allocas

Partition allocas that occur in the entry block into two categories.  The first is those whose size is fixed and alignment are less than or equal to the stack alignment.  These are emitted relative to a pointer, either in increasing offset relative to the stack pointer or decreasing offset relative to the frame pointer.  (Actually, we are not enabling this optimization for frame pointer frames yet)  The second category is allocas whose size is dynamic or alignment is creater than the stack alignment.  These are emitted relative to a user variable in increasing offset order.  This optimization is only enabled for x86 at O2.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1411583007 .

8 years agoHandle another form of MOVW in ARM integrated assembler.
Karl Schimpf [Wed, 11 Nov 2015 22:47:49 +0000 (14:47 -0800)]
Handle another form of MOVW in ARM integrated assembler.

Extends assembler movw method to handle integer constants in addition
to relocatable constants, since (32-bit) integer constants are
frequently used in movw instructions.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1440693002 .

8 years agoSubzero. ARM32. New bool folding.
John Porto [Wed, 11 Nov 2015 22:26:57 +0000 (14:26 -0800)]
Subzero. ARM32. New bool folding.

Improves the bool folding logic so that branches are short circuited.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1417393003 .

8 years agoFix line spacing for push instructions in ARM assembly.
Karl Schimpf [Wed, 11 Nov 2015 21:34:46 +0000 (13:34 -0800)]
Fix line spacing for push instructions in ARM assembly.

Removes blank line after push instructions.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1439683002 .

8 years agoImprove bool folding
David Sehr [Wed, 11 Nov 2015 18:56:58 +0000 (10:56 -0800)]
Improve bool folding

Fold and/or followed by branch to eliminate cmp.  Also, fold fcmp instructions into branches similarly to what was done for icmp instructions.

BUG=
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1436623002 .

8 years agoSubzero: For filetype=asm, don't print a blank line for pseudo instrs.
Jim Stichnoth [Tue, 10 Nov 2015 22:39:51 +0000 (14:39 -0800)]
Subzero: For filetype=asm, don't print a blank line for pseudo instrs.

Originally, for each non-deleted instruction, CfgNode::emit() would call the virtual Inst::emit() and then print a newline (also printing end-of-live-range info as necessary).  This resulted in clumsy blank lines in the asm output, corresponding to non target specific pseudo instructions such as FakeDef, FakeUse, FakeKill.

We change this so that CfgNode::emit() only prints a newline for an InstTarget subclass, or if any end-of-live-range text was printed.

If a high-level instruction still wants to emit something in a comment, it's responsible for printing its own newline.

BUG= none
TEST= ./pydir/szbuild_spec2k.py -O2 --force -v --filetype=asm --sz=--asm-verbose=0
TEST= ./pydir/szbuild_spec2k.py -O2 --force -v --filetype=asm --sz=--asm-verbose=1
TEST= ./pydir/szbuild_spec2k.py -O2 --force -v --filetype=asm --target=arm32
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1431353003 .

8 years agoAdd POP instruction to ARM integrated assembler.
Karl Schimpf [Tue, 10 Nov 2015 22:12:35 +0000 (14:12 -0800)]
Add POP instruction to ARM integrated assembler.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1433743002 .

8 years agoSubzero: Add "szbuild.py --no-sz" arg for suppressing the pnacl-sz run.
Jim Stichnoth [Tue, 10 Nov 2015 16:41:12 +0000 (08:41 -0800)]
Subzero: Add "szbuild.py --no-sz" arg for suppressing the pnacl-sz run.

This enables the following workflow:

1. Run "szbuild.py --filetype=asm ..." to generate a .s file.
2. Edit the .s file to mock up a Subzero change.
3. Run "szbuild.py --filetype=asm --no-sz ..." to restart the build post pnacl-sz.

This workflow is good for trying out localized changes to hot basic blocks, though it isn't really appropriate for global optimizations like register allocation.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1417003005 .

8 years agoDo some small cleanup in IceTLS.h and add some markup for doxygen to it.
Reed Kotler [Tue, 10 Nov 2015 00:52:56 +0000 (16:52 -0800)]
Do some small cleanup in IceTLS.h and add some markup for doxygen to it.

BUG=
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1430273004 .

Patch from Reed Kotler <rkotlerimgtec@gmail.com>.

8 years agoSubzero. ARM32. Address mode formation.
John Porto [Mon, 9 Nov 2015 22:52:40 +0000 (14:52 -0800)]
Subzero. ARM32. Address mode formation.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=kschimpf@google.com, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1422753010 .

8 years agoAdd UMULL to ARM integrated assembler.
Karl Schimpf [Mon, 9 Nov 2015 20:16:20 +0000 (12:16 -0800)]
Add UMULL to ARM integrated assembler.

Also formatted IceCfg.cpp, since it needed it.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1422253003 .

8 years agoFixes LDR and STR instructions. Two types of mistakes were being made.
Karl Schimpf [Mon, 9 Nov 2015 20:09:58 +0000 (12:09 -0800)]
Fixes LDR and STR instructions. Two types of mistakes were being made.

First, the width was not being correctly defined for non-vector
instructions.

Second, the order of the width/condition was incorrect when the
instruction was prefixed with a V. That is, for V prefixed instructions,
the order is predicate/width while for non-V prefixed instructions the
order is width/predicate.

Also fixes bug in target lowering that did not always convert results
of a compare to i1.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1415953007 .

8 years agoSubzero: Refactor x86 register representation to actively use aliases.
Jim Stichnoth [Mon, 9 Nov 2015 19:38:40 +0000 (11:38 -0800)]
Subzero: Refactor x86 register representation to actively use aliases.

Sets up additional register attributes, plus the notion of register classes, to enable robust usage of the high 8-bit GPRs (ah/bh/ch/dh), for both x86-32 and x86-64.  (Note that the x86-64 changes are currently untested.)

We add a Register Class field to the Variable class.  The default register class is a value corresponding to the variable's type, but the target can extend the set of register class values, and the target lowering can assign different register classes as needed.  The register allocator uses the register class instead of the type to determine the set of registers to draw from.

For x86-64, the high 8-bit registers are not included in the general register allocation pool, but there are explicit references to ah for lowering the div/rem instructions.

The target lowering is modified as needed to make sure types are appropriate and register use in instructions is legalized.

Some other fixes and cleanups are included in this CL:

* Makefile.standalone changes.  Source files are reordered so that the more expensive compiles are done earlier, speeding up parallel builds by decreasing fragmentation.  A dependency error is fixed for check-spec.

* A bug is fixed in advanced phi lowering.  When a temporary is introduced to break a cycle, we were neglecting to updated the predecessor count for one of the operands, leading to an assertion failure.  (Applying that fix to master resulted in no changes to spec2k code generation.)  A consistency check is added to help find future problems like this.  Also, refactored iteration over the Phi descriptor array to use range-based for loops and avoid directly indexing the array.

* Removed most of the "IceType_" prefixes in x-macro tables for brevity.

* Fix a correctness TODO in the register allocator.  This had no effect on spec2k code generation in master or in this CL, so we were probably just lucky.

* Made some much-needed s/Dest->getType()/Ty/ changes for brevity, in the target lowering sections that needed other changes.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4095
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1427973003 .

8 years agoSubzero: Fix a bug in advanced phi lowering.
Jim Stichnoth [Mon, 9 Nov 2015 19:19:11 +0000 (11:19 -0800)]
Subzero: Fix a bug in advanced phi lowering.

When a temporary is introduced to break a cycle, we neglected to update the predecessor count for one of the operands, leading to a possible assertion failure.

This problem isn't currently seen in master, but it arises when we enable register aliases, as in https://codereview.chromium.org/1427973003/ .  No changes are seen in spec2k code generation as a result of this fix.

A consistency check is added to help find future problems like this.

Also, refactored iteration over the Phi descriptor array to use range-based for loops and avoid directly indexing the array.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1435543002 .

8 years agoSubzero: Recognize single-block loops during loop depth analysis.
Jim Stichnoth [Mon, 9 Nov 2015 18:46:14 +0000 (10:46 -0800)]
Subzero: Recognize single-block loops during loop depth analysis.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1416113007 .

8 years agoSort allocas, compute frame pointer in Cfg pass
David Sehr [Fri, 6 Nov 2015 19:25:41 +0000 (11:25 -0800)]
Sort allocas, compute frame pointer in Cfg pass

Split allocas in the entry block into two categories.  The first has alignment <= stack alignment and constant size.  The second violates one or both of those conditions.  Sort both of these lists in descending alignment order and emit.  Also, compute the need for a frame pointer during the pass.

BUG=
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1414343010 .

8 years agoAdd the PUSH instruction to ARM integrated assembler.
Karl Schimpf [Fri, 6 Nov 2015 17:14:10 +0000 (09:14 -0800)]
Add the PUSH instruction to ARM integrated assembler.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1412963008 .

8 years agoFix textual emission of label instructions in ARM assembler.
Karl Schimpf [Fri, 6 Nov 2015 16:52:42 +0000 (08:52 -0800)]
Fix textual emission of label instructions in ARM assembler.

The integrated ARM assembler was incorrectly assuming that an
(instruction) label defines a corresponding assembler instruction.
Therefore, placement into the buffer was incorrect.

This CL fixes this mistake. This fixes assembler translator problems
with ARM branch, movw, and movt instructions.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1430973003 .

8 years agoLower a few basic MIPS binops for i{8,16,32,64}.
Reed Kotler [Fri, 6 Nov 2015 01:07:19 +0000 (17:07 -0800)]
Lower a few basic MIPS binops for i{8,16,32,64}.

This is basically the same patch as for ARM issue 1127003003

https://codereview.chromium.org/1127003003

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4167
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1414383004 .

Patch from Reed Kotler <rkotlerimgtec@gmail.com>.

8 years agoAdd MLA instruction to ARM integerated assembler.
Karl Schimpf [Thu, 5 Nov 2015 16:27:51 +0000 (08:27 -0800)]
Add MLA instruction to ARM integerated assembler.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1429073005 .

8 years agoFix ARM emit() methods to count instructions generated.
Karl Schimpf [Thu, 5 Nov 2015 16:18:26 +0000 (08:18 -0800)]
Fix ARM emit() methods to count instructions generated.

Previously, the code assumed that the emit() method of all ARM
instructions emitted a single instruction. This is false. Instructions
like PUSH and POP may generate multiple instructions.

This is only a problem when the hybrid ARM assembler reverts back to
using the stand-alone assembler to generate instructions the
integrated assembler can't handle.

The fix is to add infrastructure to allow ARM instructions to
communicate to the assembler, the number of instructions they
generate, so that the correct-sized filler is added to the assembly
buffer.

This fixes all cross-test failures for (pc-relative) branches, except
one.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1426513004 .

8 years agoSubzero: Refactor some common TargetLowering initializations.
Jim Stichnoth [Thu, 5 Nov 2015 00:06:16 +0000 (16:06 -0800)]
Subzero: Refactor some common TargetLowering initializations.

Each TargetLowering subclass has several fields (generally register allocation related) that are initialized to the same values every time a TargetLowering object is created.  These fields are essentially const once initialized, so there is no reason to repeatedly initialize them.

The solution is to make them static fields, and statically initialize them at program startup.

This also makes it practical to access such fields without needing a TargetLowering object.

There are likely more items that should also get this treatment, but those can be changed later.

The staticInit() method needs a run-once guard because the unit tests actually cause it to be called more than once.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1418853005 .

8 years agoAdd TST(register, immediate) to ARM32 integrated assembler.
Karl Schimpf [Wed, 4 Nov 2015 22:54:52 +0000 (14:54 -0800)]
Add TST(register, immediate) to ARM32 integrated assembler.

Also cleans up instructions that use emitType01 to share more common
code.

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1413473005 .

8 years agoMatch index adds as well as base
David Sehr [Wed, 4 Nov 2015 22:46:29 +0000 (14:46 -0800)]
Match index adds as well as base

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1421603003 .

8 years agoSubzero. ARM32. Implements bool folding.
John Porto [Wed, 4 Nov 2015 17:32:55 +0000 (09:32 -0800)]
Subzero. ARM32. Implements bool folding.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1414883007 .

8 years agoFix base register for stack variables in ARM integrated assembler.
Karl Schimpf [Wed, 4 Nov 2015 16:10:43 +0000 (08:10 -0800)]
Fix base register for stack variables in ARM integrated assembler.

When translating an Variable without a register, the code assumes the
variable is on the stack using sp. This is still true. However, if it
is a (derived class) StackVariable, the register defined by
getBaseRegNum() should be used instead.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1432453003 .

8 years agoAdd workaround to allow testing of ARM integrated assembler.
Karl Schimpf [Wed, 4 Nov 2015 16:02:07 +0000 (08:02 -0800)]
Add workaround to allow testing of ARM integrated assembler.

It turns out that there are several instruction in the ARM integrated
assembler that do not get translated correctly. This results in the
spec2k tests not being compilable.

To workaround this problem, this CL adds a (temporary) flag that allows all translations to be applied by the integrated assembler. When this flag is false (the default) only correctly working translations to be applied by the integrated assembler. This allows lit tests to still be applied to the correct portions of broken translations.

This CL also fixes a bug with local (instruction) labels that did not
generate a corresponding label to the -filetype=iasm assembly file.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1424923005 .

8 years agoAdd BIC(register) and BIC(immediate) to ARM integrated assembler.
Karl Schimpf [Mon, 2 Nov 2015 23:01:56 +0000 (15:01 -0800)]
Add BIC(register) and BIC(immediate) to ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1415943009 .

8 years agoSubzero: Add a "make check-spec" target.
Jim Stichnoth [Mon, 2 Nov 2015 16:25:57 +0000 (08:25 -0800)]
Subzero: Add a "make check-spec" target.

"make -f Makefile.standalone check-spec" will translate and run all the spec2k components for a given target.

The advantages are that this can be done all within the subzero directory, and the spec components can be run in parallel via "make -j" (particularly helpful for arm32/qemu).

Default target is x8632, and arm32 is also available.

Example:

  make -j32 -f Makefile.standalone check-spec TARGET=arm32 SPEC="-O2 --filetype=iasm"

Also removes unnecessary tab characters from the makefile, fixes >80-column lines, and gives more consistent indentation.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1413033009 .

8 years agoSubzero: Force ebp-based frame when an alloca has a large alignment.
Jim Stichnoth [Sat, 31 Oct 2015 19:55:27 +0000 (12:55 -0700)]
Subzero: Force ebp-based frame when an alloca has a large alignment.

If the alloca alignment exceeds the known ABI stack alignment, the lowering sequence adds an "and esp, xxx" instruction.  In this case, the esp adjustment is no longer statically known, so we must force an ebp-based frame.

BUG= none
R=sehr@google.com

Review URL: https://codereview.chromium.org/1426933003 .

8 years agoAdd MOV (register) to ARM integrated assembler.
Karl Schimpf [Fri, 30 Oct 2015 22:26:32 +0000 (15:26 -0700)]
Add MOV (register) to ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1403403009 .

8 years agoFix more movw/movt ARM integrated assembler tests.
Karl Schimpf [Fri, 30 Oct 2015 22:09:18 +0000 (15:09 -0700)]
Fix more movw/movt ARM integrated assembler tests.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1425243002 .

8 years agoAdd CMP(register) and CMP(Immediate) to ARM integerated assembler.
Karl Schimpf [Fri, 30 Oct 2015 22:06:35 +0000 (15:06 -0700)]
Add CMP(register) and CMP(Immediate) to ARM integerated assembler.

Also cleans up comments on rotated immediate 8 constants.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1414483008 .

8 years agoAdd UDIV to ARM integrated assembler.
Karl Schimpf [Fri, 30 Oct 2015 22:00:24 +0000 (15:00 -0700)]
Add UDIV to ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1427023004 .

8 years agoSubzero: Add a missing absolute path to llvm-mc command.
Jim Stichnoth [Fri, 30 Oct 2015 21:41:43 +0000 (14:41 -0700)]
Subzero: Add a missing absolute path to llvm-mc command.

Somehow missed this in https://codereview.chromium.org/1419173006 .

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1410813004 .

8 years agoAdd SDIV to ARM integrated assembler.
Karl Schimpf [Fri, 30 Oct 2015 20:21:59 +0000 (13:21 -0700)]
Add SDIV to ARM integrated assembler.

Also clean up some comments on where code was moved from in Dart
sourced.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1429003002 .

8 years agoDon't allow hybrid assembler unless filetype=iasm.
Karl Schimpf [Fri, 30 Oct 2015 20:19:17 +0000 (13:19 -0700)]
Don't allow hybrid assembler unless filetype=iasm.

BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1424353003 .

8 years agoSubzero: Use explicit paths to PNaCl tools invoked in szbuild.py.
Jim Stichnoth [Fri, 30 Oct 2015 19:02:44 +0000 (12:02 -0700)]
Subzero: Use explicit paths to PNaCl tools invoked in szbuild.py.

This makes it easier to copy the commands and run them manually.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1419173006 .

8 years agoAdd EOR(register) and EOR(immediate) to ARM integrated assembler.
Karl Schimpf [Fri, 30 Oct 2015 15:06:44 +0000 (08:06 -0700)]
Add EOR(register) and EOR(immediate) to ARM integrated assembler.

Also factor out code to process arguments for data operations into
new method Arm32::Assembler32::emitType01().

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1406153011 .

8 years agoAdd orr (register) and orr (immediate) to ARM integrated assembler.
Karl Schimpf [Fri, 30 Oct 2015 14:42:00 +0000 (07:42 -0700)]
Add orr (register) and orr (immediate) to ARM integrated assembler.

Also cleans up comments about handling a rotated imm8 value.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1412923006 .

8 years agoAdd new form of ldr/str (immediate) to ARM integrated assembler.
Karl Schimpf [Fri, 30 Oct 2015 14:30:14 +0000 (07:30 -0700)]
Add new form of ldr/str (immediate) to ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1431453002 .

8 years agoAdd mul instruction to ARM integrated assembler.
Karl Schimpf [Fri, 30 Oct 2015 14:25:43 +0000 (07:25 -0700)]
Add mul instruction to ARM integrated assembler.

Also cleans up a couple of template definitions by using the
appropriate "using" type name.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1430713003 .

8 years agoAdd AND(register) and AND(immediate) to ARM integrated assembler.
Karl Schimpf [Thu, 29 Oct 2015 22:50:32 +0000 (15:50 -0700)]
Add AND(register) and AND(immediate) to ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1412293006 .

8 years agoHandle MOV (immediate) and MOVT to load ARM global addresses.
Karl Schimpf [Thu, 29 Oct 2015 21:04:12 +0000 (14:04 -0700)]
Handle MOV (immediate) and MOVT to load ARM global addresses.

Adds a new type of fixup to handle the relocatable fixups needed
for movw and movt on a global addresses. Also adds movw and movt
methods to the ARM assembler.

Also makes ARM register names visible (without a target lowering
object), so that the ARM integrated assembler can generate the appropriate assembly.
Note that the integrated assembler needs to generate the
corresponding movw/movt, and follows the instruction with the bytes
that appear in the corresponding assembler buffer. This allows the
ability to test if we have generated the correct values, and will be
set up properly for ELF emission.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1424863005 .

8 years agoAdd Sbc(register) and Sbc(immediate) to integrated ARM assembler.
Karl Schimpf [Thu, 29 Oct 2015 16:11:40 +0000 (09:11 -0700)]
Add Sbc(register) and Sbc(immediate) to integrated ARM assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1424213003 .

8 years agoSets the stage for enabling the use of the 8-bit high registers, but doesn't yet...
Jim Stichnoth [Wed, 28 Oct 2015 16:26:00 +0000 (09:26 -0700)]
Sets the stage for enabling the use of the 8-bit high registers, but doesn't yet turn it on because more work is needed for correctness.

In the lowering, typing is tightened up so that we don't specify e.g. eax when we really mean ax or al.  This gets rid of the ShiftHack hack.  The one exception is the pinsr instruction which always requires an r32 register even if the memory operand is m8 or m16.

The x86 assembler unit tests are fixed, by not passing a GlobalContext arg to the Assembler ctor.

Many constexpr and "auto *" upgrades are applied.  Sorry for not putting this into a separate CL - a few local fixes got out of hand...

Tested in the following ways:
- "make check-lit" - some .ll CHECK line changes due to register randomization
- "make check-xtest"
- "make check-xtest" with forced filetype=asm (via local .py hack)
- spec2k with all -filetype options
- compare before-and-after spec2k filetype=asm output - a few differences where the correct narrow register is used instead of the full-width register

To do in the next CL:

1. Add new register classes:
  (a) 32-bit GPR truncable to 8-bit (eax, ecx, edx, ebx)
  (b) 16-bit GPR truncable to 8-bit (ax, cx, dx, bx)
  (c) 8-bit truncable from 16/32-bit (al, bl, cl, dl)
  (c) 8-bit "mov"able from ah/bh/ch/dh

2. Enable use of ah/bh/ch/dh for x86-32.

3. Enable use of ah (but skip bh/ch/dh) for x86-64.

4. Statically initialize register tables in the TargetLowering subclass.

BUG= none
R=jpp@chromium.org, kschimpf@google.com

Review URL: https://codereview.chromium.org/1419903002 .

8 years agoSubzero. ARM32. Implements the Availability Optimization.
John Porto [Wed, 28 Oct 2015 12:47:58 +0000 (05:47 -0700)]
Subzero. ARM32. Implements the Availability Optimization.

Implements the Availability optimization:

a = b
x = f(a, c)

becomes

a = b
x = f(b, c)

This only triggers if b is an infinite-weight temporary, and it
prevents a potential spill at the cost of higher register pressure.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1424873003 .

8 years agoEnhance address mode recovery
David Sehr [Tue, 27 Oct 2015 23:55:40 +0000 (16:55 -0700)]
Enhance address mode recovery

This adds some more patterns to address mode recovery to recover
ConstantRelocatables as displacements, and a few more generalizations that
catch indexed addressing.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1428443002 .

8 years agoAdd instruction 'adc (register)' to ARM integrated assembler.
Karl Schimpf [Tue, 27 Oct 2015 22:21:03 +0000 (15:21 -0700)]
Add instruction 'adc (register)' to ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1410183004 .

8 years agoFix ARM integrated assembler to be able to compile spec2k examples.
Karl Schimpf [Tue, 27 Oct 2015 22:16:27 +0000 (15:16 -0700)]
Fix ARM integrated assembler to be able to compile spec2k examples.

Fixes a couple of bugs that stopped the ARM integrated assembler from
generating assembly code for any spec2k examples.

Fixes are:

1) Handle conditional branches with no else branch.

2) Fix usage of fixups so that the emit method does any needed buffer
lookups. This fixes case where textual fixups (with zero length)
appear at the end of the assembly file.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1417173003 .

8 years agoAdd ADC (immediate) instruction to ARM integrated assembler.
Karl Schimpf [Tue, 27 Oct 2015 14:36:59 +0000 (07:36 -0700)]
Add ADC (immediate) instruction to ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1424773002 .

8 years agoHandle branch relative to pc in ARM integrated assembler.
Karl Schimpf [Tue, 27 Oct 2015 14:28:09 +0000 (07:28 -0700)]
Handle branch relative to pc in ARM integrated assembler.

Adds an explicit branch instruction (near form only), which allows
branching from the current pc up to 2**26 bytes (in either direction).
For now, this near restriction (within a function) doesn't appear to
be a bad restriction, and only near jumps have been implemented.

Also fixes notationally the concepts of the following types:

InstValueType : The 32-bit encoding of an instruction value.
InstOffsetType : Offset (+/-) used within an instruction.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1418313003 .

8 years agoGenerate block labels in the ARM hybrid assembler.
Karl Schimpf [Fri, 23 Oct 2015 16:19:48 +0000 (09:19 -0700)]
Generate block labels in the ARM hybrid assembler.

Fixes an issue where branches don't compile in the hybrid integrated
assembler because some jump instructions have not yet been integrated.
It does this by adding an instruction label for each corresponding
label generated by the standalone ARM assembler.

Note that in order to fix this, I had to change the signature of
virtual method Assembler::bindCfgNodeLabel to get the Cfg node (rather
than the index value). This allows the ARM hybrid assembler to
generate a label for each CfgNode (using the getAsmName() method).

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1407273006 .

8 years agoAdd hybrid assembler concept to ARM assembler.
Karl Schimpf [Thu, 22 Oct 2015 15:19:26 +0000 (08:19 -0700)]
Add hybrid assembler concept to ARM assembler.

Adds a notion of a hybrid assembler. That is, if the integrated
assembler can lower an instruction to bytes, it does. Otherwise, it
uses the standalone assembler to generate text as the placeholder for
the instruction. This is done using a textual fixup in the assembly
buffer.

The advantage of the hybrid assembler is that one can incrementally
implement the integrated assembler and still test the generated
assembly.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1418523002 .

8 years agoImplements simple returns and call args for Mips.
Jim Stichnoth [Wed, 21 Oct 2015 13:57:46 +0000 (06:57 -0700)]
Implements simple returns and call args for Mips.
This patch is essentially the same as for ARM https://codereview.chromium.org/1127963004

I have incorporated the new 64 bit register work which was not available
at the time of this earlier patch.

The MIPS O32 Abi is not perfect on this patch but I am more or less following
the development of the ARM patches and those were preliminary at this
stage too. I will make corrections in a later patch when I incorporate
more of the ARM patches.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4167
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1416493002 .

8 years agoemit add/sub registers instructions in integrated ARM assembler.
Karl Schimpf [Sat, 17 Oct 2015 20:00:17 +0000 (13:00 -0700)]
emit add/sub registers instructions in integrated ARM assembler.

Also cleans up comments and condition violations for all implemented ARM
instructions.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1411873002 .

8 years agoSubzero: Fix MINIMAL build issues.
Jim Stichnoth [Fri, 16 Oct 2015 20:34:54 +0000 (13:34 -0700)]
Subzero: Fix MINIMAL build issues.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1407263005 .

8 years agoMerge compares and branches
David Sehr [Fri, 16 Oct 2015 20:23:17 +0000 (13:23 -0700)]
Merge compares and branches

Generalize folding of icmp instructions into br.  64-bit comparisons are
considered as candidates unless they feed a select.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1407143002 .

8 years agoSubzero: Add -allow-extern as an alias for --allow-externally-defined-symbols.
Jim Stichnoth [Fri, 16 Oct 2015 20:13:11 +0000 (13:13 -0700)]
Subzero: Add -allow-extern as an alias for --allow-externally-defined-symbols.

Also remind the user of that option in IceConverter.cpp, similar to PNaClTranslator.cpp.

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1408023004 .

8 years agoSubzero. Misc ARM32 bugfixes.
John Porto [Fri, 16 Oct 2015 17:34:04 +0000 (10:34 -0700)]
Subzero. Misc ARM32 bugfixes.

With this CL, Spec2k built by the Sz ARM32 backend runs and verifies
successfully.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4076
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1407063002 .

8 years agoHandle stack spills in ARM integrated assembler.
Karl Schimpf [Fri, 16 Oct 2015 17:31:31 +0000 (10:31 -0700)]
Handle stack spills in ARM integrated assembler.

Add code to handle spilling stack variables. That is, add code to
handle loading and storing to stack addresses.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1402403002 .

8 years agoSubzero: Various fixes in preparation for x86-32 register aliasing.
Jim Stichnoth [Thu, 15 Oct 2015 18:10:38 +0000 (11:10 -0700)]
Subzero: Various fixes in preparation for x86-32 register aliasing.

1. Helper function sameVarOrReg() also needs to return true if the two physical registers alias or overlap.  Otherwise advanced phi lowering may pick an incorrect ordering.

2. With -asm-verbose, redundant truncation assignments expressed as _mov instructions, like "mov cl, ecx", need to have their register use counts updated properly, so that the LIVEEND= annotations are correct.

3. The register allocator should consider suitably typed aliases when choosing a register preference.

4. When evicting a variable, the register allocator should decrement the use count of all aliases.

5. When saving/restoring callee-save registers in the prolog/epilog, map each register to its "canonical" register (e.g. %bl --> %ebx) and make sure each canonical register is only considered once.

6. Remove some unnecessary Variable::setMustHaveReg() calls.

7. When assigning bool results as a constant 0 or 1, use an 8-bit constant instead of 32-bit so that only the 8-bit register gets assigned.

BUG= none
TEST= make check, plus spec2k -asm-verbose output is unchanged
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1405643003 .

8 years agoOptimize 64-bit compares with zero
David Sehr [Thu, 15 Oct 2015 17:38:53 +0000 (10:38 -0700)]
Optimize 64-bit compares with zero

Comparisons with zero can be done with no branches in most cases and with
simpler sequences of operations.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1406593003 .

8 years agoAdd "sub immediate" instruction to the ARM integrated assembler.
Karl Schimpf [Wed, 14 Oct 2015 21:30:21 +0000 (14:30 -0700)]
Add "sub immediate" instruction to the ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1388323003 .

8 years agoAdd "add immediate" instruction to the ARM integrated assembler.
Karl Schimpf [Tue, 13 Oct 2015 21:39:14 +0000 (14:39 -0700)]
Add "add immediate" instruction to the ARM integrated assembler.

Also does some bikeshed clean ups. In particualr, the (ARM)
instruction method emitIAS only needs to choose the applicable ARM
instruction, and then passes the corresponding operands to the
corresponding instruction method of the assembler. The assembler
method then extracts the appropriate data from the operands, and
decides which rule to apply for the corresponding arm instruction.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1407613002 .

8 years agoFix emission of move immediate for ARM integrated assembler.
Karl Schimpf [Tue, 13 Oct 2015 16:49:31 +0000 (09:49 -0700)]
Fix emission of move immediate for ARM integrated assembler.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4334
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1397043003 .

8 years agoSubzero: Consider all instruction variables for register preference.
Jim Stichnoth [Mon, 12 Oct 2015 22:24:46 +0000 (15:24 -0700)]
Subzero: Consider all instruction variables for register preference.

The original code only looked at top-level source operands in the defining instruction, with a TODO to instead consider all inner variables in the instruction.

The primary reason is so that we end up with more instructions like
  mov eax, eax
which are later elided as redundant assignments.

A secondary reason is to foster more instructions like:
  mov ecx, [ecx]
rather than
  mov eax, [ecx]
where ecx's live range ends.  This hopefully keeps eax (in the latter case) free for longer and maybe allow some other variable to get a register.  By considering all instruction variables, we enable this.

BUG= none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1392383003 .