LLVM backend for 6502
Go to file
Chris Lattner 62fe406dc2 implement an instcombine xform that canonicalizes casts outside of and-with-constant operations.
This fixes rdar://8808586 which observed that we used to compile:


union xy {
        struct x { _Bool b[15]; } x;
        __attribute__((packed))
        struct y {
                __attribute__((packed)) unsigned long b0to7;
                __attribute__((packed)) unsigned int b8to11;
                __attribute__((packed)) unsigned short b12to13;
                __attribute__((packed)) unsigned char b14;
        } y;
};

struct x
foo(union xy *xy)
{
        return xy->x;
}

into:

_foo:                                   ## @foo
	movq	(%rdi), %rax
	movabsq	$1095216660480, %rcx    ## imm = 0xFF00000000
	andq	%rax, %rcx
	movabsq	$-72057594037927936, %rdx ## imm = 0xFF00000000000000
	andq	%rax, %rdx
	movzbl	%al, %esi
	orq	%rdx, %rsi
	movq	%rax, %rdx
	andq	$65280, %rdx            ## imm = 0xFF00
	orq	%rsi, %rdx
	movq	%rax, %rsi
	andq	$16711680, %rsi         ## imm = 0xFF0000
	orq	%rdx, %rsi
	movl	%eax, %edx
	andl	$-16777216, %edx        ## imm = 0xFFFFFFFFFF000000
	orq	%rsi, %rdx
	orq	%rcx, %rdx
	movabsq	$280375465082880, %rcx  ## imm = 0xFF0000000000
	movq	%rax, %rsi
	andq	%rcx, %rsi
	orq	%rdx, %rsi
	movabsq	$71776119061217280, %r8 ## imm = 0xFF000000000000
	andq	%r8, %rax
	orq	%rsi, %rax
	movzwl	12(%rdi), %edx
	movzbl	14(%rdi), %esi
	shlq	$16, %rsi
	orl	%edx, %esi
	movq	%rsi, %r9
	shlq	$32, %r9
	movl	8(%rdi), %edx
	orq	%r9, %rdx
	andq	%rdx, %rcx
	movzbl	%sil, %esi
	shlq	$32, %rsi
	orq	%rcx, %rsi
	movl	%edx, %ecx
	andl	$-16777216, %ecx        ## imm = 0xFFFFFFFFFF000000
	orq	%rsi, %rcx
	movq	%rdx, %rsi
	andq	$16711680, %rsi         ## imm = 0xFF0000
	orq	%rcx, %rsi
	movq	%rdx, %rcx
	andq	$65280, %rcx            ## imm = 0xFF00
	orq	%rsi, %rcx
	movzbl	%dl, %esi
	orq	%rcx, %rsi
	andq	%r8, %rdx
	orq	%rsi, %rdx
	ret

We now compile this into:

_foo:                                   ## @foo
## BB#0:                                ## %entry
	movzwl	12(%rdi), %eax
	movzbl	14(%rdi), %ecx
	shlq	$16, %rcx
	orl	%eax, %ecx
	shlq	$32, %rcx
	movl	8(%rdi), %edx
	orq	%rcx, %rdx
	movq	(%rdi), %rax
	ret

A small improvement :-)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123520 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-15 06:32:33 +00:00
autoconf autoconf: Add --disable-embed-stdcxx to suppress linking libstdc++.a into llvm.dll with --enable-shared on Cygming. 2010-12-29 03:59:14 +00:00
bindings Fix OCaml bindings crash, PR8847. 2010-12-23 15:49:26 +00:00
cmake Add some platform tests. 2011-01-13 19:17:28 +00:00
docs Don't document exactly how virtual registers are represented as integers. Code 2011-01-08 23:10:59 +00:00
examples Do not re-test for the existence of pthread.h. 2010-12-23 21:27:22 +00:00
include fix typo 2011-01-15 06:27:35 +00:00
lib implement an instcombine xform that canonicalizes casts outside of and-with-constant operations. 2011-01-15 06:32:33 +00:00
projects Regen configure 2010-12-12 21:42:01 +00:00
runtime
test implement an instcombine xform that canonicalizes casts outside of and-with-constant operations. 2011-01-15 06:32:33 +00:00
tools Fix memory leak found by clang static analyzer. 2011-01-14 22:34:17 +00:00
unittests Disable RTTI when building unit tests. This avoids errors at link time. 2011-01-13 15:31:45 +00:00
utils Fix some tablegen issues to allow using zero_reg for InstAlias definitions. 2011-01-14 22:58:09 +00:00
website
.gitignore Cleanup and document .gitignore. 2010-12-17 17:22:50 +00:00
build-for-llvm-top.sh
CMakeLists.txt Add to the CMake build some options and platform tests supported by 2011-01-11 12:31:54 +00:00
configure autoconf: Add --disable-embed-stdcxx to suppress linking libstdc++.a into llvm.dll with --enable-shared on Cygming. 2010-12-29 03:59:14 +00:00
CREDITS.TXT Another git svn dcommit test. This time let's hope it doesn't kill my repo. 2010-12-10 14:45:10 +00:00
LICENSE.TXT
llvm.spec.in
Makefile Merge System into Support. 2010-11-29 18:16:10 +00:00
Makefile.common
Makefile.config.in autoconf: Add --disable-embed-stdcxx to suppress linking libstdc++.a into llvm.dll with --enable-shared on Cygming. 2010-12-29 03:59:14 +00:00
Makefile.rules build: Shared libraries shouldn't used RPATH on Darwin, only main executables 2010-12-08 02:29:26 +00:00
ModuleInfo.txt Remove trailing space. This is just an excuse to poke the 2010-10-05 20:32:15 +00:00
README.txt Undoing test commit blank space. 2010-09-29 17:39:29 +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.