mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-16 11:30:51 +00:00
5a70dd1d82
Similar to gep (r230786) and load (r230794) changes. Similar migration script can be used to update test cases, which successfully migrated all of LLVM and Polly, but about 4 test cases needed manually changes in Clang. (this script will read the contents of stdin and massage it into stdout - wrap it in the 'apply.sh' script shown in previous commits + xargs to apply it over a large set of test cases) import fileinput import sys import re rep = re.compile(r"(getelementptr(?:\s+inbounds)?\s*\()((<\d*\s+x\s+)?([^@]*?)(|\s*addrspace\(\d+\))\s*\*(?(3)>)\s*)(?=$|%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|zeroinitializer|<|\[\[[a-zA-Z]|\{\{)", re.MULTILINE | re.DOTALL) def conv(match): line = match.group(1) line += match.group(4) line += ", " line += match.group(2) return line line = sys.stdin.read() off = 0 for match in re.finditer(rep, line): sys.stdout.write(line[off:match.start()]) sys.stdout.write(conv(match)) off = match.end() sys.stdout.write(line[off:]) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232184 91177308-0d34-0410-b5e6-96231b3b80d8
42 lines
1.7 KiB
LLVM
42 lines
1.7 KiB
LLVM
; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
|
|
|
|
@.str = private unnamed_addr constant [8 x i8] c"%d, %d\0A\00", align 1
|
|
|
|
define i32 @foo(i32* %mem, i32 %val, i32 %c) nounwind {
|
|
entry:
|
|
%0 = atomicrmw add i32* %mem, i32 %val seq_cst
|
|
%add = add nsw i32 %0, %c
|
|
ret i32 %add
|
|
; 16-LABEL: foo:
|
|
; 16: lw ${{[0-9]+}}, %call16(__sync_synchronize)(${{[0-9]+}})
|
|
; 16: lw ${{[0-9]+}}, %call16(__sync_fetch_and_add_4)(${{[0-9]+}})
|
|
}
|
|
|
|
define i32 @main() nounwind {
|
|
entry:
|
|
%x = alloca i32, align 4
|
|
store volatile i32 0, i32* %x, align 4
|
|
%0 = atomicrmw add i32* %x, i32 1 seq_cst
|
|
%add.i = add nsw i32 %0, 2
|
|
%1 = load volatile i32, i32* %x, align 4
|
|
%call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 %add.i, i32 %1) nounwind
|
|
%pair = cmpxchg i32* %x, i32 1, i32 2 seq_cst seq_cst
|
|
%2 = extractvalue { i32, i1 } %pair, 0
|
|
%3 = load volatile i32, i32* %x, align 4
|
|
%call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 %2, i32 %3) nounwind
|
|
%4 = atomicrmw xchg i32* %x, i32 1 seq_cst
|
|
%5 = load volatile i32, i32* %x, align 4
|
|
%call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 %4, i32 %5) nounwind
|
|
; 16-LABEL: main:
|
|
; 16: lw ${{[0-9]+}}, %call16(__sync_synchronize)(${{[0-9]+}})
|
|
; 16: lw ${{[0-9]+}}, %call16(__sync_fetch_and_add_4)(${{[0-9]+}})
|
|
; 16: lw ${{[0-9]+}}, %call16(__sync_val_compare_and_swap_4)(${{[0-9]+}})
|
|
; 16: lw ${{[0-9]+}}, %call16(__sync_lock_test_and_set_4)(${{[0-9]+}})
|
|
|
|
ret i32 0
|
|
}
|
|
|
|
declare i32 @printf(i8* nocapture, ...) nounwind
|
|
|
|
|