LLVM backend for 6502
Go to file
Bill Wendling de2b151dbf Consider this code snippet:
float t1(int argc) {
  return (argc == 1123) ? 1.234f : 2.38213f;
}

We would generate truly awful code on ARM (those with a weak stomach should look
away):

_t1:
  movw   r1, #1123
  movs   r2, #1
  movs   r3, #0
  cmp    r0, r1
  mov.w  r0, #0
  it     eq
  moveq  r0, r2
  movs   r1, #4
  cmp    r0, #0
  it     ne
  movne  r3, r1
  adr    r0, #LCPI1_0
  ldr    r0, [r0, r3]
  bx     lr

The problem was that legalization was creating a cascade of SELECT_CC nodes, for
for the comparison of "argc == 1123" which was fed into a SELECT node for the ?:
statement which was itself converted to a SELECT_CC node. This is because the
ARM back-end doesn't have custom lowering for SELECT nodes, so it used the
default "Expand".

I added a fairly simple "LowerSELECT" to the ARM back-end. It takes care of this
testcase, but can obviously be expanded to include more cases.

Now we generate this, which looks optimal to me:

_t1:
  movw   r1, #1123
  movs   r2, #0
  cmp    r0, r1
  adr    r0, #LCPI0_0
  it     eq
  moveq  r2, #4
  ldr    r0, [r0, r2]
  bx     lr
  .align  2
LCPI0_0:
  .long   1075344593  @ float 2.382130e+00
  .long   1067316150  @ float 1.234000e+00



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110799 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11 08:43:16 +00:00
autoconf Add a bit of a hack to avoid multiple defines of variables in 2010-08-08 09:18:29 +00:00
bindings
cmake CMake: corrections on LLVM.cmake external services. 2010-08-11 00:51:32 +00:00
docs CMake: document how to incorporate LLVM into the cmake project of an 2010-08-09 03:26:48 +00:00
examples upgrade to use new intrinsics, patch by Dan Hipschman! 2010-08-10 21:45:38 +00:00
include llvm-mc: Add -show-inst-operands, for dumping the parsed instruction representation before matching. 2010-08-11 06:37:09 +00:00
lib Consider this code snippet: 2010-08-11 08:43:16 +00:00
projects
runtime
test Consider this code snippet: 2010-08-11 08:43:16 +00:00
tools llvm-mc: Add -show-inst-operands, for dumping the parsed instruction representation before matching. 2010-08-11 06:37:09 +00:00
unittests Remove the ValueMap copy constructor. It's not used anywhere, 2010-08-08 12:57:48 +00:00
utils tblgen/AsmMatcher: Treat '.' in assembly strings as a token separator. 2010-08-11 06:36:59 +00:00
website
build-for-llvm-top.sh
CMakeLists.txt CMake: system for providing llvm-config-like features to the user. 2010-08-09 03:26:43 +00:00
configure Regenerate. 2010-08-08 09:20:39 +00:00
CREDITS.TXT
LICENSE.TXT
llvm.spec.in
Makefile tests: Kill off custom targets which were just there for TestRunner.sh. 2010-08-02 00:52:44 +00:00
Makefile.common
Makefile.config.in Make the makefiles go much faster by using the realpath 2010-08-03 22:53:22 +00:00
Makefile.rules Simplify generating LLVMC_BUILTIN_PLUGIN. 2010-08-10 14:49:29 +00:00
ModuleInfo.txt
README.txt (Hopefully) One last test. 2010-07-27 00:04:55 +00:00

\Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for the Low Level
Virtual Machine, a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the HTML documentation provided in docs/index.html for further
assistance with LLVM.

If you're writing a package for LLVM, see docs/Packaging.html for our
suggestions.